コード例 #1
0
        public bool Update(WAMS_SUPPLIER entity, List <WAMS_PRODUCT> entityDetails, string LstDeleteDetailItem)
        {
            _repository.Update(entity);
            if (entityDetails != null)
            {
                foreach (var detail in entityDetails)
                {
                    if (detail.Id != 0)
                    {
                        var detailEntity = _repositoryDetail.GetByKey(detail.Id);
                        detailEntity.bSupplierID  = entity.bSupplierID;
                        detailEntity.vProductID   = detail.vProductID;
                        detailEntity.vDescription = detail.vDescription;
                        detailEntity.dModified    = DateTime.Now;
                        detailEntity.iModified    = entity.iModified;
                        _repositoryDetail.Update(detailEntity);
                    }
                    else
                    {
                        var detailEntity = new WAMS_PRODUCT
                        {
                            bSupplierID  = entity.bSupplierID,
                            vProductID   = detail.vProductID,
                            vDescription = detail.vDescription,
                            iEnable      = true,
                            dCreated     = entity.dCreated,
                            iCreated     = entity.iCreated
                        };
                        _repositoryDetail.Add(detailEntity);
                    }
                }

                if (!string.IsNullOrEmpty(LstDeleteDetailItem))
                {
                    var listStrLineElements = LstDeleteDetailItem.Split(';').ToList();
                    foreach (var itemDetail in listStrLineElements)
                    {
                        _customRepository.DeleteDetail(Convert.ToInt32(itemDetail));
                    }
                }
            }
            _unitOfWork.CommitChanges();
            return(true);
        }
コード例 #2
0
 public bool Insert(WAMS_SUPPLIER entity, List <WAMS_PRODUCT> entityDetails)
 {
     _repository.Add(entity);
     _unitOfWork.CommitChanges();
     if (entityDetails != null)
     {
         foreach (var detail in entityDetails)
         {
             var detailEntity = new WAMS_PRODUCT
             {
                 vProductID   = detail.vProductID,
                 bSupplierID  = entity.bSupplierID,
                 vDescription = detail.vDescription,
                 iEnable      = true,
                 dCreated     = entity.dCreated,
                 iCreated     = entity.iCreated
             };
             _repositoryDetail.Add(detailEntity);
         }
     }
     _unitOfWork.CommitChanges();
     return(true);
 }