public override Guid GetExecutor(Guid documentId, Guid activityTypeId, int orderNum) { //return Guid.NewGuid(); const string ai = "abdukayumov.i"; //"19c786af-da7a-499d-b9ef-f17055029e3e"; const string nep = "nesipbaeva.g"; //2E9F5803-DE7F-4784-A391-FAE9C9E4E74D DirectionToPayRepository repository = new DirectionToPayRepository(false); var directionToPay = repository.GetAsQuarable(d => d.Id == documentId).FirstOrDefault(); if (directionToPay == null) { return(Guid.Empty); } if (directionToPay.Type == EXP_DirectionToPaysView.ExpertWorkType) { var emp = repository.GetEmployList().FirstOrDefault(e => e.Login == ai); if (emp != null) { return(emp.Id); } } else { var emp = repository.GetEmployList().FirstOrDefault(e => e.Login == nep); if (emp != null) { return(emp.Id); } } return(directionToPay.CreateEmployeeId); }
public JsonResult CreateDirectionPriceList(EXP_PriceListDirectionToPayView model) { DirectionToPayRepository repository = new DirectionToPayRepository(); // if (ModelState.IsValid) { EXP_DirectionToPays_PriceList m = new EXP_DirectionToPays_PriceList() { DirectionToPayId = model.DirectionToPayId.Value, PriceListId = model.PriceListId.Value, Price = model.Price, Count = model.Count, Total = model.Price * model.Count }; var diretionToPay = repository.GetAsQuarable(d => d.Id == model.DirectionToPayId.Value).FirstOrDefault(); if (diretionToPay != null) { diretionToPay.TotalPrice += m.Total; repository.Update(diretionToPay); } repository.InsertDirectionPriceList(m); repository.Save(); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateDirectionPriceList(EXP_PriceListDirectionToPayView model) { if (ModelState.IsValid) { DirectionToPayRepository repository = new DirectionToPayRepository(); EXP_DirectionToPays_PriceList m = repository.GetDirectionPriceList(dp => dp.DirectionToPayId == model.DirectionToPayId && dp.PriceListId == model.Id).FirstOrDefault(); if (m != null) { m.Count = model.Count; m.Price = model.Price; m.Total = model.Total; repository.UpdateDirectionPriceList(m); repository.Save(); } var diretionToPay = repository.GetAsQuarable(d => d.Id == model.DirectionToPayId.Value).FirstOrDefault(); if (diretionToPay != null) { diretionToPay.TotalPrice = 0; foreach (var pl in diretionToPay.EXP_DirectionToPays_PriceList) { diretionToPay.TotalPrice += pl.Total; } repository.Update(diretionToPay); repository.Save(); } } return(Json(model, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteDirectionPriceList(EXP_PriceListDirectionToPayView model) { if (model != null) { DirectionToPayRepository repository = new DirectionToPayRepository(); repository.DeleteDirectionPriceList(model.DirectionToPayId.Value, model.Id); repository.Save(); var diretionToPay = repository.GetAsQuarable(d => d.Id == model.DirectionToPayId.Value).FirstOrDefault(); if (diretionToPay != null) { diretionToPay.TotalPrice = 0; foreach (var pl in diretionToPay.EXP_DirectionToPays_PriceList) { diretionToPay.TotalPrice += pl.Total; } repository.Update(diretionToPay); repository.Save(); } } return(Json(model, JsonRequestBehavior.AllowGet)); }
public ActionResult CreateCertificateOfCompletion(int stageId, Guid drugDeclarationId) { CertificateOfCompletionRepository repository = new CertificateOfCompletionRepository(); DictionaryRepository dictionary = new DictionaryRepository(false); var newStatusId = dictionary.GetDictionaryElementIdByTypeAndCode(Dictionary.CertificateOfCompletionStatusDic.DicCode, Dictionary.CertificateOfCompletionStatusDic.New); DirectionToPayRepository directionRepository = new DirectionToPayRepository(false); var directionToPay = directionRepository.GetAsQuarable( d => d.EXP_DrugDeclaration.Any(dd => dd.Id == drugDeclarationId) && d.Type == EXP_DirectionToPaysView.ExpertWorkType && d.DeleteDate == null).FirstOrDefault(); if (directionToPay != null) { var cert = repository.GetAsQuarable(coc => coc.DicStageId == stageId && coc.DrugDeclarationId == drugDeclarationId && coc.DeleteDate == null).FirstOrDefault(); bool isExist = cert != null; if (!isExist) { cert = new EXP_CertificateOfCompletion() { Id = Guid.NewGuid(), Number = Registrator.GetNumber("CertificateOfCompletion").ToString(), CreateEmployeeId = UserHelper.GetCurrentEmployee().Id, CreateDate = DateTime.Now, DeleteDate = null, ModifyDate = null, SendDate = null, StatusId = newStatusId, DicStageId = stageId, DrugDeclarationId = drugDeclarationId } } ; switch (stageId) { case CodeConstManager.STAGE_PRIMARY: cert.TotalPrice = directionToPay.TotalPrice * (decimal)0.7; break; case CodeConstManager.STAGE_SAFETYREPORT: cert.TotalPrice = directionToPay.TotalPrice * (decimal)0.3; break; default: break; } if (isExist) { repository.Update(cert); } else { repository.Insert(cert); } repository.Save(); } else { return(Json(new { IsSuccess = false, Message = "Отсутствует направление на оплату" }, JsonRequestBehavior.AllowGet)); } return(Json(new { IsSuccess = true, Message = "" }, JsonRequestBehavior.AllowGet)); }