public async Task <IActionResult> AddProduct() { var addProdcutVM = new EditProductShowViewModel(); var brands = await _brandRepo.GetBrandsAsync(null, null, null); var selectBrands = brands.Select(b => new { b.Title, b.Id }); var groups = await _groupRepo.GetGroupsAsync(null, null, null, null); var selectGroups = groups.Select(g => new { g.Title, g.Id }); addProdcutVM.BrandGroupViewModel = new BrandGroupViewModel { Brand = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(selectBrands, "Id", "Title"), Group = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(selectGroups, "Id", "Title") }; return(View(addProdcutVM)); }
public async Task <IActionResult> EditProduct(int id) { ViewBag.Id = id; var editProductVM = new EditProductShowViewModel(); var brands = await _brandRepo.GetBrandsAsync(null, null, null); var selectBrands = brands.Select(b => new { b.Title, b.Id }); editProductVM.Product = await _productRepo.GetProductAsync(id); var groups = await _groupRepo.GetGroupsAsync(null, null, null, null); var selectGroups = groups.Select(g => new { g.Title, g.Id }); editProductVM.BrandGroupViewModel = new BrandGroupViewModel { Brand = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(brands, "Id", "Title", editProductVM.Product.BrandId), Group = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(groups, "Id", "Title", editProductVM.Product.GroupId) }; return(View("AddProduct", editProductVM)); }