public async Task <IActionResult> Edit(int id) { if (id == 0) { return(RedirectToAction("Index")); } var colors = await _styleService.GetColors(); var sizes = await _styleService.GetSizes(); ViewBag.ColorId = new SelectList(colors, "Id", "ColorText"); ViewBag.SizeId = new SelectList(sizes, "Id", "SizeText"); var products = await _productService.FindIncludeAll(id); var model = new EditProductViewModel { Product = await _productService.FindIncludeAll(id), Colors = colors?.OrderBy(x => x.ColorText), Sizes = sizes?.OrderBy(x => x.SizeOrder) }; return(View(model)); }