public void Insert(ProdCategoryView model) { using (var rep = new ProdCategoryRepository()) { rep.Insert(ConvertToProduct(model)); } }
private static ProdCategory ConvertToProduct(ProdCategoryView modelView) { var dev = new ProdCategory { CategoryId = modelView.CategoryId, CategoryName = modelView.CategoryName, }; return dev; }
public ActionResult Update(ProdCategoryView model, int id) { try { if (!ModelState.IsValid) return View(model); model.CategoryId = id; obj.Update(model); return RedirectToAction("Index"); } catch { return View(model); } }
public ActionResult Create(ProdCategoryView model) { var user = User.Identity.Name; try { if (!ModelState.IsValid) return View(model); obj.Insert(model); return RedirectToAction("Index"); } catch { return View(model); } }
public void Update(ProdCategoryView modelView) { using (var rep = new ProdCategoryRepository()) { var dev = rep.GetById(modelView.CategoryId); if (dev != null) { dev.CategoryName = modelView.CategoryName; rep.Update(dev); } } }