public async Task<ActionResult> Create(DepartmentCreateViewModel model) { try { if (ModelState.IsValid) { var dep = model.ToModel(); await this._departmentAggregateManagementService.AddDepartmentAsync(dep); return RedirectToAction("Index"); } return View(model); // TODO: Add insert logic here } catch { return View(model); } }
public async Task<ActionResult> Create() { try { DepartmentCreateViewModel model = new DepartmentCreateViewModel(); var fmodel = await _organizationManagementService.GetAllFacilitiesAsync(); if (fmodel != null) { model.FacilitiesModel = fmodel.Select(x => new SelectListItem() { Value = x.Id.ToString() + "#$#" + x.Name.Replace(" ", "#+#"), Text = x.Name }); } return View(model); } catch { return View(); } }