Пример #1
0
 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();
     }
 }
Пример #2
0
 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);
     }
 }
Пример #3
0
        //
        // GET: /Category/Create

        public ActionResult Create()
        {
            var model = new CategoryModel();
            return View(model);
        }
Пример #4
0
 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();
     }
 }