public ActionResult Edit(int id, ShopDAL.DomainModel.Category category) { try { facade.GetCategoryService().Update(id, category); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult CreateChild(int id, ShopDAL.DomainModel.Category category) { //Checks if the category name is already exists if (category.CategoryName == facade.GetCategoryService().FindName(category.CategoryName)) { ModelState.AddModelError("CategoryName", "Category already exists"); return(View()); } else { facade.GetCategoryService().AddCategoryWithId(id, category); return(RedirectToAction("Index")); } }
public ActionResult Create([Bind(Include = "id, CategoryName, ChildOf")] ShopDAL.DomainModel.Category category) { //Checks if the category name is already exists if (category.CategoryName == facade.GetCategoryService().FindName(category.CategoryName)) { ModelState.AddModelError("CategoryName", "Category already exists"); return(View()); } else { facade.GetCategoryService().AddCategory(category); return(Redirect("Index")); } }
public ActionResult Upload(int id, HttpPostedFileBase file, ShopDAL.DomainModel.Category category) { if (file != null && file.ContentLength > 0) { try { string path = Path.Combine(Server.MapPath("~/img")); file.SaveAs(path); facade.GetCategoryService().Update(id, category); ViewBag.Message = "File uploaded successfully"; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { ViewBag.Message = "You have not specified a file."; } return(RedirectToAction("Edit", new { id = category.id })); }