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