public ActionResult Create(ProductSizes productSizes) { if (ModelState.IsValid) { Handler.AddProductSize(productSizes); List <ProductSizes> list = Handler.GetProductByName(Handler.GetProductById(productSizes.ProductId).Name); int quantity = 0; foreach (ProductSizes item in list) { quantity += item.Quantity; } Handler.AddStock(new Stock() { ProductId = productSizes.ProductId, Quantity = quantity }); return(RedirectToAction("Index", "ProductSize")); } ViewBag.SizeId = new SelectList(Context.Categories, "Id", "Name", productSizes.SizeId); ViewBag.ProductId = new SelectList(Context.Categories, "Id", "Name", productSizes.ProductId); return(View(productSizes)); }