public ActionResult Delete(VitaminsItemViewModel item) { _context.Remove(item.Id); return(RedirectToAction("Index")); // return View(); }
public ActionResult Edit(int id) { /// var product = _context.Get_Vitamin(id); if (product != null) { VitaminsItemViewModel model = new VitaminsItemViewModel { Name = product.Name, Discription = product.Discription, Id = product.Id //Price = product.Price, //DateCreate = product.CreateDate, //LastChange = product.LastChange, //Category = new CategoriesItemViewModel { Id = product.Categories.Id, Name = product.Categories.Name }, //CategoryList = _context2.Get_All().Select //(x => new SelectItemViewModel //{ // Id = x.Id, // Name = x.Name //} //).ToList() }; return(View(model)); } return(View()); }
public ActionResult Delete(int id) { var item = _context.Get_Vitamin(id); VitaminsItemViewModel model = new VitaminsItemViewModel { Id = item.Id, Discription = item.Discription, Name = item.Name, //DateCreate = item.CreateDate, //Price = item.Price }; return(View(model)); }
public ActionResult Edit(VitaminsItemViewModel item) { var product = _context.Get_Vitamin(item.Id); if (product != null && ModelState.IsValid) { product.Name = item.Name; product.Discription = item.Discription; //product.Price = item.Price; //product.Categories = _context2.Get_Category(item.Category.Id); //product.LastChange = DateTime.Now; _context.SaveChange(); return(RedirectToAction("Index")); } return(View()); }