public void InsertManagerCatalogCategoryEdit(CatalogCategoryEditViewModel model) { var item = Mapper.Map <Catalog_Categories>(model); m_ContentContext.Catalog_Categories.Add(item); m_ContentContext.SaveChanges(); }
public void UpdateManagerCatalogCategoryEdit(CatalogCategoryEditViewModel model) { var query = from c in m_ContentContext.Catalog_Categories where c.Id == model.Id select c; var item = query.FirstOrDefault(); Mapper.Map(model, item); m_ContentContext.SaveChanges(); }
//GET: Admin/CatalogManager/CreateCategory public ActionResult CreateCategory() { this.StatusList(1); var model = new CatalogCategoryEditViewModel { Status = 1, Pos = 1 }; ViewBag.CategoryTree = m_catalogWorker.GetCategoryTree(); return(View(model)); }
public ActionResult EditCategory(CatalogCategoryEditViewModel model) { if (ModelState.IsValid) { try { m_catalogWorker.UpdateManagerCatalogCategoryEdit(model); return(RedirectToAction("Categories")); } catch (Exception ex) { ModelState.AddModelError("General", ex.Message); } } this.StatusList(model.Status); ViewBag.CategoryTree = m_catalogWorker.GetCategoryTree(); return(View(model)); }