// GET: Products/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var product = await _productServices.GetProductById((int)id, new string[] { "User", "Stock", "Brand" }); if (product == null) { return(NotFound()); } var lstSupplies = await _userServices.GetSupply(); var currentBrand = await _brandServices.GetBrandById(product.BrandId); var currentStock = await _stockServices.GetStockById(product.StockId); var currentSupply = lstSupplies.FirstOrDefault(x => x.Id == product.SupplyId).SupplyName; ViewData["BrandId"] = new SelectList(await _brandServices.GetBrand(), "Id", "ShortName", product.Brand.ShortName); ViewData["StockId"] = new SelectList(await _stockServices.GetStock(), "Id", "Name", product.Stock.Name); ViewData["SupplyId"] = new SelectList(lstSupplies, "Id", "SupplyName", product.User.SupplyName); return(View(product)); }