Exemple #1
0
        public ActionResult Edit(Category tag)
        {
            SetViewBag();
            var dao   = new CategoriesDao();
            var model = dao.ListAll();

            if (ModelState.IsValid)
            {
                var result = dao.Update(tag);

                if (result)
                {
                    return(RedirectToAction("Index", "Category", model));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật không thành công");
                }
            }
            return(View("Edit"));
        }
Exemple #2
0
 public ActionResult Edit(Category category)
 {
     if (ModelState.IsValid)
     {
         if (!category.Image.IsNullOrWhiteSpace() && category.Image.Contains("/"))
         {
             category.Image = splitImage(Request["Image"]);
         }
         if (!category.Icon.IsNullOrWhiteSpace() && category.Icon.Contains("/"))
         {
             category.Icon = splitImage(Request["Icon"]);
         }
         if (dao.Update(category))
         {
             SetAlert("Edit Category success", "success");
             return(RedirectToAction("Index", "Categories"));
         }
         else
         {
             SetAlert("Edit Failed", "error");
         }
     }
     return(View(category));
 }