public ActionResult Create([Bind(Include = "Id,Name")] Models.ProductMVC product) { if (ModelState.IsValid) { var item = new Modell.Product() { Id = product.Id, ProductName = product.Name }; new DAL.Repository.ProductRepository() .Insert(item); return(RedirectToAction("Index")); } return(View(product)); }
public ActionResult Edit([Bind(Include = "Id,Name")] Models.ProductMVC product) { if (ModelState.IsValid) { var item = new DAL.Repository.ProductRepository() .GetById(product.Id) .FirstOrDefault(); if (item != null) { item.ProductName = product.Name; new DAL.Repository.ProductRepository() .Update(item); return(RedirectToAction("Index")); } } return(View(product)); }