public IActionResult Details(int?id) { List <ProductView> productView = new List <ProductView>(); if (id != null) { Product product = db.Products.FirstOrDefault(x => x.ProductId == id); Models.Sneaker sneaker = db.Sneakers.FirstOrDefault(x => x.SneakerId == product.SneakerId); Img img = db.Imgs.FirstOrDefault(x => x.SneakerId == product.SneakerId); Brand brand = db.Brands.FirstOrDefault(x => x.Id == sneaker.BrandId); Material material = db.Materials.FirstOrDefault(x => x.Id == sneaker.MaterialId); Category category = db.Categories.FirstOrDefault(x => x.Id == sneaker.CategoryId); List <ProductSize> productSize = db.ProductSizes.Where(x => x.ProductId == product.ProductId).Include(x => x.Size).OrderBy(x => x.Size.Number).ToList(); productView.Add(new ProductView { Id = product.ProductId, Name = sneaker.SneakerName, Amount = product.Amount, UrlImage = img.ImgUrl, Price = product.Price, Description = sneaker.Description, BrandName = brand.BrandName, CategoryName = category.CategoryName, MaterialName = material.MaterialName, Sizes = productSize }); if (productView != null) { return(View(productView)); } } return(NotFound()); }
public async Task <IActionResult> Create(Models.Sneaker sneaker, SneakerAll sneakerAll) { if (ModelState.IsValid) { sneaker.SneakerId = sneakerAll.Id; sneaker.Description = sneakerAll.Descriptions; sneaker.SneakerName = sneakerAll.Name; sneaker.CategoryId = sneakerAll.SelectedCategory; sneaker.MaterialId = sneakerAll.SelectedMaterial; sneaker.BrandId = sneakerAll.SelectedBrand; br.Create(sneaker); br.Save(); return(RedirectToAction("Index")); } return(View(sneakerAll)); }
public async Task <IActionResult> Delete(int id) { Models.Sneaker sneaker = br.Get(id); return(View(sneaker)); }