public ActionResult Factory() { FactoryProduction productionInfo = new FactoryProduction(); var ProductInf = AgroExpressDBAccess.GetAllEnabledProduct(); ProductInf = ProductInf.Where(a => a.ProductName.ToLower() != "milk").ToList(); 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; productionInfo.ConsumptionDate = System.DateTime.Now.Date; return(View(productionInfo)); }
public ActionResult GetCustomProduction() { var viewModel = new FactoryProduction { Message = "" }; return(View("CustomProduction", viewModel)); }
public ActionResult PostCustomProduction([Bind(Include = "Quantity,Type,Gender,Size,Color")] FactoryProduction viewModel) { if (!ModelState.IsValid) { return(View("CustomProduction", viewModel)); } Factory.ClothesProduction(viewModel); return(View("CustomProduction", viewModel)); }
//[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)); }
public void ProductionEventSuccess() { FactoryProduction p = null; foreach (GameEvent e in _tm.GetQueuedEvents()) { if (e is FactoryProduction) { p = (FactoryProduction)e; break; } } var player = _f.GetComponent <DrillerCarrier>().GetOwner(); var totalDrillers = _game.TimeMachine.GetState().GetPlayerDrillerCount(player); var drillerCap = _game.TimeMachine.GetState().GetPlayerDrillerCapacity(player); Assert.IsNotNull(p); Assert.IsTrue(totalDrillers < drillerCap); _tm.GoTo(p.GetOccursAt().Advance(10)); Assert.IsTrue(_tm.GetCurrentTick().GetTick() > p.GetOccursAt().GetTick()); Assert.IsTrue(p.WasEventSuccessful()); }
public static void ClothesProduction(FactoryProduction viewModel) { ApplicationDbContext db = new ApplicationDbContext(); var factory = db.Factories.Single(); var clothesSupplies = db.FactorySumSupplies.SingleOrDefault(); switch (viewModel.Type) { case ProductType.T_Shirt: decimal requiredClothquantityForT_Shirts = Convert.ToDecimal(viewModel.Quantity * 1.5); int requiredButtonQuantityForT_Shirts = viewModel.Quantity * 3; int requiredStickerQuantityForT_Shirts = viewModel.Quantity * 2; decimal requiredThreadQuantityForT_Shirts = Convert.ToDecimal(viewModel.Quantity * 1.2); if (clothesSupplies.Cloth > requiredClothquantityForT_Shirts && clothesSupplies.Buttons > requiredButtonQuantityForT_Shirts && clothesSupplies.Stickers > requiredStickerQuantityForT_Shirts && clothesSupplies.Thread > requiredThreadQuantityForT_Shirts) { clothesSupplies.Cloth = clothesSupplies.Cloth - requiredClothquantityForT_Shirts; clothesSupplies.Buttons = clothesSupplies.Buttons - requiredButtonQuantityForT_Shirts; clothesSupplies.Stickers -= requiredStickerQuantityForT_Shirts; clothesSupplies.Thread -= requiredThreadQuantityForT_Shirts; factory.ClothesDailyProdutionLog = viewModel.Quantity.ToString() + " Date: " + DateTime.Now.ToString("dd/MM/yyyy"); var product = db.Products .Where(p => p.Color == viewModel.Color && p.Gender == viewModel.Gender && p.Size == viewModel.Size && p.Type == viewModel.Type).Single(); product.WarehouseQuantity += viewModel.Quantity; db.SaveChanges(); viewModel.Message = "Your Order Sent to Production!"; } else { viewModel.Message = "Not enough Supplies to Produce this Order!"; } break; case ProductType.Trousers: decimal requiredClothquantityForTrousers = Convert.ToDecimal(viewModel.Quantity * 1.4); int requiredButtonQuantityForTrousers = viewModel.Quantity * 8; int requiredStickerQuantityForTrousers = viewModel.Quantity * 2; decimal requiredThreadQuantityForTrousers = Convert.ToDecimal(viewModel.Quantity * 1.4); decimal requiredZippersQuantityForTrousers = Convert.ToDecimal(viewModel.Quantity * 1); if (clothesSupplies.Cloth > requiredClothquantityForTrousers && clothesSupplies.Buttons > requiredButtonQuantityForTrousers && clothesSupplies.Thread > requiredThreadQuantityForTrousers && clothesSupplies.Stickers > requiredStickerQuantityForTrousers && clothesSupplies.Zipper > requiredZippersQuantityForTrousers) { clothesSupplies.Cloth = clothesSupplies.Cloth - requiredClothquantityForTrousers; clothesSupplies.Buttons = clothesSupplies.Buttons - requiredButtonQuantityForTrousers; clothesSupplies.Thread -= requiredThreadQuantityForTrousers; clothesSupplies.Stickers -= requiredStickerQuantityForTrousers; clothesSupplies.Zipper -= requiredZippersQuantityForTrousers; factory.TrousersDailyProdutionLog = viewModel.Quantity.ToString() + " Date: " + DateTime.Now.ToString("dd/MM/yyyy"); var product = db.Products .Where(p => p.Color == viewModel.Color && p.Gender == viewModel.Gender && p.Size == viewModel.Size && p.Type == viewModel.Type).Single(); product.WarehouseQuantity += viewModel.Quantity; db.SaveChanges(); viewModel.Message = "Your Order Sent to Production!"; } else { viewModel.Message = "Not enough Supplies to Produce this Order!"; } break; default: break; } }