public async Task<ActionResult> Create(EquipmentCreateViewModel model) { try { if (ModelState.IsValid) { var equip = model.ToModel(); await this._equipmentAggregateManagementService.AddEquipmentAsync(equip); return RedirectToAction("Index"); } return View(model); // TODO: Add insert logic here } catch { return View(model); } }
// GET: Equipment/Create public async Task<ActionResult> Create() { try { EquipmentCreateViewModel model = new EquipmentCreateViewModel(); var fmodel = await _departmentAggregateManagementService.GetAllDepartmentsAsync(); 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(); } }