public ActionResult Create() { var model = new AdminGroupProductViewModel(); ViewBag.Groups = Repository.GroupProduct.FetchAll().Where(g => g.ParentGroupID == null); return(View(model)); }
public ActionResult Create(AdminGroupProductViewModel model) { if (ModelState.IsValid) { var group = Mapper.Map <GroupProduct>(model); Repository.GroupProduct.Insert(group); Repository.GroupProduct.SaveChanges(); if (group.GroupID != 0) { return(RedirectToAction("Index", "Category")); } } ViewBag.Groups = Repository.GroupProduct.FetchAll().Where(g => g.ParentGroupID == null); return(View(model)); }