public ActionResult Create(ClientVisitSaveDataModel model) { model.Comment = model.Comment + Environment.NewLine + " Место выдачи: " + model.DeliveryCenters.Where(a => a.Value == model.DeliveryCenterId.ToString()).Select(b => b.Text).FirstOrDefault() + Environment.NewLine + " Категория клиента: " + model.UralsibClientCategories.Where(a => a.Value == model.ClientCategoryId.ToString()).Select(b => b.Text).FirstOrDefault() + Environment.NewLine; model.Registrator = new UserModel(userBusinessLogic.User_GetByLogin(this.HttpContext.User.Identity.Name)); model.Validate(new ModelValidationContext() { currenUser = CurrentUser }); model.IsSuccessfullySaved = model.IsValid(); if (model.IsValid()) { ClientVisitSaveResult result = clientBusinessLogic.ClientVisit_Save(CurrentUser, model.GetClientVisitSaveData()); model.VisitGroupId = result.VisitGroupId; model.VisitId = result.ClientVisitID; model.ClientId = result.ClientID; if (!string.IsNullOrEmpty(model.TemporaryPolicyNumber)) { BSOSaveDataModel bsoSaveDataModel = new BSOSaveDataModel(bsoBusinessLogic.BSO_GetByNumber(model.TemporaryPolicyNumber)); bsoBusinessLogic.BSO_Save((bsoSaveDataModel.UpdateBSOIssuedClient(model, CurrentUser)).GetBSOSaveData()); } //return RedirectToAction("Details", "Client", new { id = result.ClientID }); model.SetFlagPrintReport(); return(View(model)); } else { return(View(model)); } }
public ActionResult Edit(BSOSaveDataModel model) { long?BSO_Id = model.Id; model.Validate(new ModelValidationContext() { currenUser = CurrentUser }); model.IsSuccessfullySaved = model.IsValid(); model.GetAvailableBSOStatus(model.StatusId, true); if (Request.IsAjaxRequest()) { if (model.IsValid()) { model.UserId = CurrentUser.Id; if (model.StatusId == (long)ListBSOStatusID.OnDelivery) { model.FlagPrintReport = true; } bsoBusinessLogic.BSO_Save(model.GetBSOSaveData()); return(PartialView("Edit", model)); } else { return(PartialView("Edit", model)); } } else { if (model.IsValid()) { model.UserId = CurrentUser.Id; bsoBusinessLogic.BSO_Save(model.GetBSOSaveData()); return(RedirectToAction("BSOHistory", "BSO", new { id = BSO_Id })); } else { return(View("BSO")); //return RedirectToAction("BSOHistory", "BSO", new { id = BSO_Id }); } } }