//[AcceptVerbs(HttpVerbs.Post)] public ActionResult Factory(FactoryProduction productionInfo) { List <Production> ProductionList = new List <Production>(); string name = HttpContext.User.Identity.Name; string operatorName = AgroExpressDBAccess.GetFullNamebyUserID(name); foreach (var production in productionInfo.productionlist) { if (production.PKProductId != null && production.Amount != null) { ProductionList.Add(new Production { ProductId = (int)production.PKProductId, Amount = (double)production.Amount, Date = production.Date, OperatorName = operatorName }); } } if (productionInfo.ConsumptionDate != null && productionInfo.MilkConsumption != null) { AgroExpressDBAccess.AddFactoryMilkConsumption((DateTime)productionInfo.ConsumptionDate, (double)productionInfo.MilkConsumption); } string message = AgroExpressDBAccess.AddPoductionList(ProductionList); if (message == "yes") { return(RedirectToAction(nameof(Factory))); } else { var ProductInf = AgroExpressDBAccess.GetAllEnabledProduct(); int len = ProductInf.Count; List <ProductionInfo> NewProduction = new List <ProductionInfo>(); for (int i = 0; i < len; i++) { NewProduction.Add(new ProductionInfo { productlist = ProductInf.Select(x => new SelectListItem { Value = x.PKProductId.ToString(), Text = x.ProductName }), Date = System.DateTime.Now, Amount = 0 }); } productionInfo.productionlist = NewProduction; ViewBag.message = message; } return(View(productionInfo)); }