public ActionResult Details(int id) { var product = _context.GetProduct(id); if (product != null) { ProductsItemsViewModel model = new ProductsItemsViewModel { Name = product.Name, Discription = product.Discription, Price = product.Price, ImagePath = product.Image, DateCreate = product.CreateDate, LastChange = product.LastChange, Category = product.Categories.Select(x => new CategoriesItemViewModel { Discription = x.Discription, Name = x.Name }).ToList(), CategoryId = product.Categories.Select(x => x.Id), 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.GetProduct(id); ProductsItemsViewModel model = new ProductsItemsViewModel { Id = item.Id, DateCreate = item.CreateDate, Discription = item.Discription, Name = item.Name, Price = item.Price }; return(View(model)); }