public BaseResponse <List <OwnDrugDtlModel> > SaveOwnDrugDtl(OwnDrugDtlList request) { BaseResponse <List <OwnDrugDtlModel> > response = new BaseResponse <List <OwnDrugDtlModel> >(); if (request.OwnDrugDtlLists != null) { if (request.OwnDrugDtlLists.Count > 0) { unitOfWork.BeginTransaction(); //先全部delete var befSaveOwnDrugDtl = unitOfWork.GetRepository <LTC_OWNDRUGDTL>().dbSet.Where(m => m.OWNDRUGID == request.UpdateOwnDrugId && m.ISDELETE == false).ToList(); if (befSaveOwnDrugDtl != null) { foreach (var bef in befSaveOwnDrugDtl) { base.SoftDelete <LTC_OWNDRUGDTL>(bef.ID); } } #region 自带药品明细 foreach (var item in request.OwnDrugDtlLists) { item.UpdateBy = SecurityHelper.CurrentPrincipal.EmpNo; item.UpdateTime = DateTime.Now; LTC_OWNDRUGDTL model = new LTC_OWNDRUGDTL(); model.ID = item.Id; model.DRUGID = item.DrugId; model.OWNDRUGID = item.OwnDrugId; model.MCDRUGCODE = item.MCDrugCode; model.NSDRUGCODE = item.NSDrugCode; model.CNNAME = item.CNName; model.QTY = item.Qty; model.UNITS = item.Units; model.MANUFACTURER = item.Manufacturer; model.BATCHNO = item.BatchNo; model.COMMENT = item.Comment; model.CREATEBY = SecurityHelper.CurrentPrincipal.EmpNo; model.CREATETIME = DateTime.Now; model.ISDELETE = false; unitOfWork.GetRepository <LTC_OWNDRUGDTL>().Insert(model); //var ownDrugDtl = unitOfWork.GetRepository<LTC_OWNDRUGDTL>().dbSet.Where(m => m.ID == item.Id).FirstOrDefault(); //if (ownDrugDtl != null) //{ // ownDrugDtl.UPDATEBY = SecurityHelper.CurrentPrincipal.EmpNo; // ownDrugDtl.CREATETIME = DateTime.Now; // unitOfWork.GetRepository<LTC_OWNDRUGDTL>().Update(ownDrugDtl); //}else //{ // LTC_OWNDRUGDTL model = new LTC_OWNDRUGDTL(); // model.ID = item.Id; // model.OWNDRUGID = item.OwnDrugId; // model.MCDRUGCODE = item.MCDrugCode; // model.NSDRUGCODE = item.NSDrugCode; // model.CNNAME = item.CNName; // model.QTY = item.Qty; // model.UNITS = item.Units; // model.MANUFACTURER = item.Manufacturer; // model.BATCHNO = item.BatchNo; // model.COMMENT = item.Comment; // model.CREATEBY = SecurityHelper.CurrentPrincipal.EmpNo; // model.CREATETIME = DateTime.Now; // model.ISDELETE = false; // unitOfWork.GetRepository<LTC_OWNDRUGDTL>().Insert(model); //} } unitOfWork.Save(); unitOfWork.Commit(); #endregion } } else { response.ResultCode = -1; response.ResultMessage = "未查询到自带药品信息!"; } return(response); }
public IHttpActionResult SaveOwnDrugDtl(OwnDrugDtlList baseRequest) { var response = service.SaveOwnDrugDtl(baseRequest); return(Ok(response)); }