¶Ô±ÈÐÂÎļþ |
| | |
| | | using AutoMapper; |
| | | using SqlSugar.Extensions; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_BasicRepository; |
| | | using WIDESEA_Common.MaterielEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_BasicService |
| | | { |
| | | public class SupplierInfoService : ServiceBase<Dt_SupplierInfo, ISupplierInfoRepository>, ISupplierInfoService |
| | | { |
| | | public ISupplierInfoRepository Repository => BaseDal; |
| | | |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IMapper _mapper; |
| | | public SupplierInfoService(ISupplierInfoRepository BaseDal,IUnitOfWorkManage unitOfWorkManage,IMapper mapper) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _mapper = mapper; |
| | | } |
| | | /// <summary> |
| | | /// æ·»å èåä¾åºåä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="bSTSupplierDTOs"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AddSupplier(List<BSTSupplierDTO> bSTSupplierDTOs) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_SupplierInfo> OldsupplierInfos = BaseDal.QueryData(x => x.InvOrgId == MaterielInvOrgEnum.èå.ObjToInt()); |
| | | //夿é夿å
¥ |
| | | Dt_SupplierInfo? ExistSupplier = OldsupplierInfos.FirstOrDefault(x => bSTSupplierDTOs.Where(x => x.Way == 1).Select(x => x.VendId).Contains(x.SupplierSourceId)); |
| | | if (ExistSupplier != null) |
| | | { |
| | | return content.Error($"ç©æId{nameof(BSTSupplierDTO.VendId)}:{ExistSupplier.SupplierSourceId}å·²åå¨"); |
| | | } |
| | | List<Dt_SupplierInfo> supplierInfos = new List<Dt_SupplierInfo>(); |
| | | foreach (var item in bSTSupplierDTOs) |
| | | { |
| | | Dt_SupplierInfo supplierInfo = _mapper.Map<Dt_SupplierInfo>(item); |
| | | supplierInfos.Add(supplierInfo); |
| | | } |
| | | BaseDal.AddData(supplierInfos); |
| | | content.OK("æ¥æ¶æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |