public async Task<IActionResult> EditSgd(Guid id, string returnUrl, ImlOrganizationExtFullDTO model) { if (id != model.Id) { return NotFound(); } if (string.IsNullOrEmpty(model.EDRPOU)) { ModelState.Clear(); ModelState.AddModelError("EDRPOU", "Поле необхідне для заповнення"); return View(model); } if (model.StreetId != Guid.Empty && model.CityId != Guid.Empty) { // ATU var newSubjAddress = new SubjectAddress { StreetId = model.StreetId, PostIndex = model.PostIndex, Building = model.Building, }; if (!_atuAddressService.SaveAddress(newSubjAddress)) { ModelState.Clear(); ModelState.AddModelError("", "Вулиця не знайдена у довіднику"); return View(model); } else { model.AddressId = newSubjAddress.Id; } } var errors = await _service.SaveNewOrg(model); if (errors.Any()) { foreach (var (key, value) in errors) { ModelState.Clear(); ModelState.AddModelError(key, value); } return View(model); } return await Task.Run(() => { return Redirect(returnUrl.Contains('?') ? $"{returnUrl}&orgId={model.Id}" : $"{returnUrl}?orgId={model.Id}"); }); }
public override async Task <IActionResult> Edit(Guid id, ImlAppDetailDTO model) { if (id != model.Id) { return(NotFound()); } if (string.IsNullOrEmpty(model.EDRPOU) && string.IsNullOrEmpty(model.INN)) { ModelState.Clear(); ModelState.AddModelError("EDRPOU", "Поле необхідне для заповнення"); ModelState.AddModelError("INN", "Поле необхідне для заповнення"); return(View(model)); } if (model.OrgType == OrgType.FOP) { if (model.PassportNumber.Length != 6 && model.PassportNumber.Length != 9) { ModelState.AddModelError("PassportNumber", "Довжина номеру паспорту має бути 6, або 9 (при викориристанні ID-картки)"); return(View(model)); } if (string.IsNullOrEmpty(model.PassportSerial)) { if (model.PassportNumber.Length != 9) { ModelState.AddModelError("PassportSerial", "Поле необхідне для заповнення (при використанні паспорту)"); return(View(model)); } } } if (model.StreetId != Guid.Empty && model.CityId != Guid.Empty) { // ATU var newSubjAddress = new SubjectAddress { StreetId = model.StreetId, PostIndex = model.PostIndex, Building = model.Building, }; if (!_atuAddressService.SaveAddress(newSubjAddress)) { ModelState.AddModelError("", "Вулиця не знайдена у довіднику"); return(View(model)); } else { model.AddressId = newSubjAddress.Id; } } var appId = await _imlApplicationService.SaveApplication(model, true); return(RedirectToAction("Details", new { id = appId })); }
public override async Task <IActionResult> Edit(Guid id, PrlAppDetailDTO model) { if (id != model.Id)//check { return(NotFound()); } if (model.OrgType == OrgType.FOP) { if (ModelState.ContainsKey("EDRPOU")) { ModelState["EDRPOU"].ValidationState = ModelValidationState.Valid; } if (ModelState.ContainsKey("OrgDirector")) { ModelState["OrgDirector"].ValidationState = ModelValidationState.Valid; } if (model.PassportNumber.Length != 6 && model.PassportNumber.Length != 9) { ModelState.AddModelError("PassportNumber", "Довжина номеру паспорту має бути 6, або 9 (при викориристанні ID-картки)"); } if (string.IsNullOrEmpty(model.PassportSerial)) { if (model.PassportNumber.Length != 9) { ModelState.AddModelError("PassportSerial", "Поле необхідне для заповнення (при використанні паспорту)"); } } } else { if (ModelState.ContainsKey("INN")) { ModelState["INN"].ValidationState = ModelValidationState.Valid; } if (ModelState.ContainsKey("PassportSerial")) { ModelState["PassportSerial"].ValidationState = ModelValidationState.Valid; } if (ModelState.ContainsKey("PassportNumber")) { ModelState["PassportNumber"].ValidationState = ModelValidationState.Valid; } if (ModelState.ContainsKey("PassportDate")) { ModelState["PassportDate"].ValidationState = ModelValidationState.Valid; } if (ModelState.ContainsKey("PassportIssueUnit")) { ModelState["PassportIssueUnit"].ValidationState = ModelValidationState.Valid; } } if (ModelState.ContainsKey("EconomicClassificationType")) { ModelState["EconomicClassificationType"].ValidationState = ModelValidationState.Valid; } if (ModelState.IsValid) { // ATU var newSubjAddress = new SubjectAddress { StreetId = model.StreetId, PostIndex = model.PostIndex, Building = model.Building, }; if (!_atuAddressService.SaveAddress(newSubjAddress)) { ModelState.AddModelError("", "Вулиця не знайдена у довіднику"); } else { model.AddressId = newSubjAddress.Id; } } if (ModelState.IsValid) { var appId = await _prlApplicationService.SaveApplication(model); return(RedirectToAction("Details", new { id = appId })); } return(View(model)); }
public override async Task <IActionResult> Edit(Guid id, TrlAppDetailDTO model) { if (!model.ListOfTrlActivityType?.Any() ?? true) { ModelState.AddModelError("ListOfTrlActivityType", "Має бути обрано щонайменьше один вид діяльності"); var activityTypeList = _service.DataService.GetEntity <EnumRecord>(x => x.EnumType == "TrlActivityType"); ViewBag.trlActivityTypeList = new MultiSelectList(activityTypeList, nameof(EnumRecord.Id), nameof(EnumRecord.Name)); } if (model.OrgType == OrgType.FOP) { if (ModelState.ContainsKey("EDRPOU")) { ModelState["EDRPOU"].ValidationState = ModelValidationState.Valid; } if (ModelState.ContainsKey("OrgDirector")) { ModelState["OrgDirector"].ValidationState = ModelValidationState.Valid; } if (model.PassportNumber.Length != 6 && model.PassportNumber.Length != 9) { ModelState.AddModelError("PassportNumber", "Довжина номеру паспорту має бути 6, або 9 (при викориристанні ID-картки)"); } if (string.IsNullOrEmpty(model.PassportSerial)) { if (model.PassportNumber.Length != 9) { ModelState.AddModelError("PassportSerial", "Поле необхідне для заповнення (при використанні паспорту)"); } } } else { if (ModelState.ContainsKey("INN")) { ModelState["INN"].ValidationState = ModelValidationState.Valid; } if (ModelState.ContainsKey("PassportSerial")) { ModelState["PassportSerial"].ValidationState = ModelValidationState.Valid; } if (ModelState.ContainsKey("PassportNumber")) { ModelState["PassportNumber"].ValidationState = ModelValidationState.Valid; } if (ModelState.ContainsKey("PassportDate")) { ModelState["PassportDate"].ValidationState = ModelValidationState.Valid; } if (ModelState.ContainsKey("PassportIssueUnit")) { ModelState["PassportIssueUnit"].ValidationState = ModelValidationState.Valid; } } if (ModelState.IsValid) { // ATU var newSubjAddress = new SubjectAddress { StreetId = model.StreetId, PostIndex = model.PostIndex, Building = model.Building, }; if (!_atuAddressService.SaveAddress(newSubjAddress)) { ModelState.AddModelError("", "Вулиця не знайдена у довіднику"); } else { model.AddressId = newSubjAddress.Id; } } if (ModelState.IsValid) { var appId = await _service.SaveApplication(model); return(RedirectToAction("Details", new { id = appId })); } return(View(model)); }
public override async Task <IActionResult> Edit(Guid id, BranchDetailsDTO model) { if (id != model.Id) { return(await Task.Run(() => NotFound())); } if (string.IsNullOrEmpty(model.AdressEng)) { ModelState.Remove("AdressEng"); } if (ModelState.IsValid) { // ATU var newSubjAddress = new SubjectAddress { StreetId = model.StreetId, PostIndex = model.PostIndex, Building = model.Building, }; if (!_atuAddressService.SaveAddress(newSubjAddress)) { ModelState.AddModelError("", "Вулиця не знайдена у довіднику"); } else { model.AddressId = newSubjAddress.Id; } } if (model.AppType == "TRL") { if (!model.TrlActivityType?.Any() ?? true) { ModelState.AddModelError("TrlActivityType", "Мае бути обрано щонайменьше один вид діяльності!"); } if (string.IsNullOrEmpty(model.BranchType)) { ModelState.AddModelError("BranchType", "Поле необхідне для заповнення!"); } if (model.BranchType == "PharmacyItem" && model.PharmacyId == null) { ModelState.AddModelError("PharmacyId", "Оберіть аптеку!"); } } if (ModelState.IsValid) { try { await _branchService.Save(model); } catch (Exception) { return(await Task.Run(() => NotFound())); } return(Json(new { status = "success", tab = "#branch" })); } return(Json(new { status = "false", errors = ModelState.Values.Where(i => i.Errors.Count > 0) })); }