public ActionResult ConfirmSendTo1CTmcs(Guid id) { ApplicationPoaRepository repo = new ApplicationPoaRepository(false); var tmcin = repo.GetAsQuarable(o => o.Id == id).FirstOrDefault(); if (tmcin != null) { tmcin.StateType = TmcIn.TmcInStatuses.SendedAdmission1C; repo.Update(tmcin); repo.Save(); } return(Json(id, JsonRequestBehavior.AllowGet)); }
public ActionResult DestroyApplication([DataSourceRequest] DataSourceRequest request, TmcInView model) { if (model != null) { TmcRepository tRepo = new TmcRepository(false); tRepo.RemoveTmcByPoaId(model.Id); tRepo.Save(); ApplicationPoaRepository repo = new ApplicationPoaRepository(false); TmcIn d = repo.GetAsQuarable(o => o.Id == model.Id).FirstOrDefault(); repo.Delete(d); repo.Save(); } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
public ActionResult UpdateApplication([DataSourceRequest] DataSourceRequest request, TmcInView model) { if (model.Id == Guid.Empty) { model.Id = model.TmcInId; } ApplicationPoaRepository repo = new ApplicationPoaRepository(false); TmcIn d = repo.GetAsQuarable(o => o.Id == model.Id).FirstOrDefault(); bool isContractChange = d.ContractNumber != model.ContractNumber; d.StateType = model.StateType; d.ContractDate = model.ContractDate; d.ContractNumber = model.ContractNumber; d.IsFullDelivery = model.IsFullDelivery; d.LastDeliveryDate = model.LastDeliveryDate; d.OwnerEmployeeId = model.OwnerEmployeeId; d.Provider = model.Provider; d.ProviderBin = model.ProviderBin; d.ExecutorEmployeeId = model.ExecutorEmployeeId; d.AgreementEmployeeId = model.AgreementEmployeeId; d.AccountantEmployeeId = model.AccountantEmployeeId; repo.Save(); model = repo.GetTmcInViews(o => o.Id == d.Id).FirstOrDefault(); if (isContractChange) { TmcRepository tmcRepo = new TmcRepository(); tmcRepo.RemoveTmcByPoaId(model.Id); var dicRepo = new DictionaryRepository(false); var contractProducts = tmcRepo.GetI1cLimsContractProducts(lc => lc.ContractNumber == d.ContractNumber); foreach (var prod in contractProducts.ToList()) { var measureId = dicRepo.GetDictionaryIdByTypeAndDisplayName(Dictionary.MeasureType.DicCode, prod.Unit); var tmc = new Tmc() { Id = Guid.NewGuid(), CreatedDate = DateTime.Now, CreatedEmployeeId = UserHelper.GetCurrentEmployee().Id, TmcInId = d.Id, StateType = 0, Number = prod.ProductId, Code = prod.ProductId, Name = prod.Name, Count = prod.QuantityVolume.Value, CountActual = prod.QuantityVolume.Value, CountFact = prod.QuantityVolume.Value, CountConvert = prod.QuantityVolume.Value, MeasureTypeDicId = measureId, MeasureTypeConvertDicId = measureId }; var tmcExist = tmcRepo.GetAsQuarable(t => t.Number == tmc.Number && t.CountFact < t.Count).FirstOrDefault(); if (tmcExist == null) { tmcRepo.Insert(tmc); var limsTmc = new LimsTmcTemp() { TmcId = tmc.Id, TmcInId = tmc.TmcInId, CreatedDate = DateTime.Now, CountRequest = tmc.Count, IsSelected = false }; repo.AddLimsTmcTemp(limsTmc); } else { var limsTmc = new LimsTmcTemp() { TmcId = tmc.Id, TmcInId = tmc.TmcInId, CreatedDate = DateTime.Now, CountRequest = prod.QuantityVolume.Value - tmcExist.CountFact, IsSelected = false }; if (prod.QuantityVolume.Value - tmcExist.CountFact > 0) { repo.AddLimsTmcTemp(limsTmc); } } } tmcRepo.Save(); repo.Save(); } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }