public async Task<ActionResult> Edit(int id, DepartmentModel model) { try { if (id == 0) return RedirectToAction("Index"); var department = Mapper.Map<DepartmentModel, Department>(model); await _departmentService.UpdateAsync(department); return RedirectToAction("Index"); } catch { return View(); } }
public async Task<ActionResult> Create(DepartmentModel model) //FormCollection collection { try { // TODO: Add insert logic here if (model == null) return View(); var department = Mapper.Map<DepartmentModel, Department>(model); await _departmentService.InsertAsync(department); return RedirectToAction("Index"); } catch { return View(model); } }
// // GET: /Category/Create public ActionResult Create() { var model = new DepartmentModel(); return View(model); }
public async Task<ActionResult> Delete(int id, DepartmentModel model) { try { if (id == 0) return RedirectToAction("Index"); await _departmentService.DeleteAsync(id); return RedirectToAction("Index"); } catch { return View(); } }