protected override RecipeModel EntityToModel(Recipe entity) { Brew entityBrew = entity.Brew; Entities.Resource entityResource = entity.Resource; return(new RecipeModel() { Amount = entity.Amount, Brew = entity.Brew != null ? new BrewModel() { BrewId = entityBrew.BrewId, Description = entityBrew.Description != null ? entityBrew.Description : string.Empty, IsRemoved = entityBrew.IsRemoved, Link = entityBrew.Link != null ? entityBrew.Link : UnitConstants.NotAny, Name = entityBrew.Name, } : null, BrewId = entity.BrewId, Description = entity.Description, Resource = new ResourceModel() { AmountInStock = entityResource.AmountInStock, IsRemoved = entityResource.IsRemoved, Link = entityResource.Link != null ? entityResource.Link : UnitConstants.NotAny, Name = entityResource.Name, ResourceId = entityResource.ResourceId, Unit = entityResource.Unit }, ResourceId = entity.ResourceId }); }
public async Task <IActionResult> Post([FromBody] Brew brew) { using (SqlConnection conn = Connection) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = @" INSERT INTO Brew (CoffeeDose, WaterDose, WaterTemp, Bloom, BrewTime, Rating, BrewDate, GrindSetting, GrinderId, Notes, BrewMethodId, BeanId, UserId) OUTPUT INSERTED.Id VALUES (@CoffeeDose, @WaterDose, @WaterTemp, @Bloom, @BrewTime, @Rating, @BrewDate, @GrindSetting, @GrinderId, @Notes, @BrewMethodId, @BeanId, @UserId)"; cmd.Parameters.Add(new SqlParameter("@CoffeeDose", brew.CoffeeDose)); cmd.Parameters.Add(new SqlParameter("@WaterDose", brew.WaterDose)); cmd.Parameters.Add(new SqlParameter("@WaterTemp", brew.WaterTemp)); cmd.Parameters.Add(new SqlParameter("@Bloom", brew.Bloom)); cmd.Parameters.Add(new SqlParameter("@BrewTime", brew.BrewTime)); cmd.Parameters.Add(new SqlParameter("@Rating", brew.Rating)); cmd.Parameters.Add(new SqlParameter("@BrewDate", brew.BrewDate)); cmd.Parameters.Add(new SqlParameter("@GrindSetting", brew.GrindSetting)); cmd.Parameters.Add(new SqlParameter("@GrinderId", brew.GrinderId)); cmd.Parameters.Add(new SqlParameter("@Notes", brew.Notes)); cmd.Parameters.Add(new SqlParameter("@BrewMethodId", brew.BrewMethodId)); cmd.Parameters.Add(new SqlParameter("@BeanId", brew.BeanId)); cmd.Parameters.Add(new SqlParameter("@UserId", brew.UserId)); int id = (int)cmd.ExecuteScalar(); brew.Id = id; return(CreatedAtRoute("GetBrew", new { id = id }, brew)); } } }
public Action GetResource(Brew brew) { Console.Error.WriteLine($"GetResource Brew"); var requiredRes = new int[4]; requiredRes[0] = brew.Delta[0] - myInv[0]; requiredRes[1] = brew.Delta[1] - myInv[1]; requiredRes[2] = brew.Delta[2] - myInv[2]; requiredRes[3] = brew.Delta[3] - myInv[3]; for (var i = 3; i >= 0; i--) { // already have enough of this res if (requiredRes[i] <= 0) { continue; } // find spell that produces this res and can be cast var action = GetResource(i, true); if (action != null) { return(action); } } // no spell to cast return(null); }
public async Task <IActionResult> Edit(int id, [Bind("BrewID,CreateDate,Name,Description,Style,Yield,OriginalGravity,FinalGravity,ABV")] Brew brew) { if (id != brew.BrewID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(brew); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BrewExists(brew.BrewID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(brew)); }
/// public List <Brew> get_BrewDB() { List <Brew> brew_list = new List <Brew>(); SqlConnection con = null; try { con = connect("DBConnectionString"); String query = "SELECT * FROM [Brew_2020]"; SqlCommand cmd = new SqlCommand(query, con); cmd.CommandTimeout = 480; SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // the connection will close as reading completes while (dr.Read()) { // Read till the end of the data into a row Brew br = new Brew(); br.Batch_id = Convert.ToInt32(dr["batch_id"]); if ((string)dr["prodItems"] == "") // No Recipe For batch Exception { brew_list.Add(br); continue; } string[] parsed_items_in_recipe = ((string)dr["prodItems"]).Split(','); List <Product> prd_lst = new List <Product>(); for (int i = 0; i < parsed_items_in_recipe.Length; i++) { Product prod = new Product(); prod.ProductName = parsed_items_in_recipe[i].Split(':')[0]; prod.Amount = (float)Convert.ToDouble(parsed_items_in_recipe[i].Split(':')[1]); prod.Min_amount = 0; prd_lst.Add(prod); } br.Prod_list = prd_lst; brew_list.Add(br); } return(brew_list); } catch (Exception ex) { throw (ex); } finally { if (con != null) { con.Close(); } } }
public void GetBestActionTest_FourEarth() { var g = new Game(); var state = new State { ActionTaken = null, Casts = new Dictionary <int, Cast> { { _waterWater.Id, _waterWater }, { _waterToEarth.Id, _waterToEarth }, { _earthToFire.Id, _earthToFire }, { _fireToAir.Id, _fireToAir } }, Tome = new List <Learn> { _F_WEE, _EEE_FFF, _WE_A, _A_WWEE, _EEE_WWFF, _F_WWWWE }, Inventory = new int[4] { 3, 0, 0, 0 } }; var goal = new Brew { Id = rand.Next(), Price = 17, Delta = new int[] { 0, 4, 0, 0 } }; var t = new TreeNode <State>(state); var quickestToBrew = g.GetBestAction(t, goal); Console.WriteLine(quickestToBrew.Count); Console.WriteLine(quickestToBrew.Select(q => q.Value.ToString() + $" nodeTally:{q.Tally}" + $"bestTally{q.Parent?.Children.Max(c => c.Tally)}").Aggregate((a, b) => a + "\n" + b)); Console.WriteLine(t.Depth); Console.WriteLine(t.NumberOfChildren); //var sb = new StringBuilder(); //PrintTree(t, "", true, sb); //File.WriteAllText(@"tree.txt", sb.ToString()); }
public async Task <IActionResult> PutBrew([FromRoute] Guid id, [FromBody] Brew brew) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != brew.ID) { return(BadRequest()); } _context.Entry(brew).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BrewExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ChemistryMajor() { health = 17; maxHP = 17; strength = 4; power = 0; charge = 0; defense = 0; guard = 0; baseAccuracy = 11; accuracy = 11; dexterity = 2; evasion = 0; type = "Chemistry Major"; passive = new Catalyst(this); quirk = Quirk.GetQuirk(this); special = new Brew(); special2 = new UnstableLiquid(); player = false; champion = false; recruitable = true; flasks = 4; CreateDrops(); attackEffect = "chance to poison"; }
public bool CanMakeBrew(Brew brew) { return (myInv[0] >= brew.Delta[0] && myInv[1] >= brew.Delta[1] && myInv[2] >= brew.Delta[2] && myInv[3] >= brew.Delta[3]); }
public ActionResult DeleteConfirmed(int id) { Brew brew = context.Brews.Find(id); context.Brews.Remove(brew); context.SaveChanges(); return(RedirectToAction("Index")); }
public bool CanMakeBrew(Brew brew, int[] inv) { return (inv[0] >= brew.Delta[0] && inv[1] >= brew.Delta[1] && inv[2] >= brew.Delta[2] && inv[3] >= brew.Delta[3]); }
public override void Execute() { brewingProcessHandler.StartMashCopperMashingIn(_startTime, _brewNumber, _fieldName, _fieldValue); Brew brew = brewingProcessHandler.GetBrew(_brewNumber); string mashingInTime = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.MashingInStartTime.ToString()); Console.WriteLine("Mash Copper Mashing In time: " + mashingInTime); }
public ActionResult Edit([Bind(Include = "ID,Description,StartDate,BottleDate,StartingGravity,FinalGravity,SecondaryFermentationDate,Variables")] Brew brew) { if (ModelState.IsValid) { context.Entry(brew).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index")); } return(View(brew)); }
public void SetEndTime(string paramText, string endTime, MashTun mashTun, Brew brew) { if (paramText.Equals("Sacha. Rest time - Finish")) { MashTunProcessParameters paramToCheck = MashTunProcessParameters.ProteinRestEndTime; MashTunProcessParameters paramToChange = MashTunProcessParameters.SacharificationRestEndTime; IMashTunState newState = mashTun.HeatingUpState; SetProcessStepEndTime(endTime, mashTun, brew, paramToCheck, paramToChange, newState); } }
public HoldingVessel() { _brew = new Brew(); _idleState = new HoldingVesselIdleState(); _fillingState = new HoldingVesselFillingState(); //_transferToWcState = new HoldingVesselTransferToWcState(); _rinsingState = new HoldingVesselRinsingState(); _currentState = _idleState; }
public void SetEndTime(string paramText, string endTime, MashTun mashTun, Brew brew) { if (paramText.Equals("Protein Rest Time - Finish")) { MashTunProcessParameters paramToCheck = MashTunProcessParameters.MashingInEndTime; MashTunProcessParameters paramToChange = MashTunProcessParameters.ProteinRestEndTime; IMashTunState newState = mashTun.SacRestState; SetProcessStepEndTime(endTime, mashTun, brew, paramToCheck, paramToChange, newState); } }
public void SetEndTime(string paramText, string endTime, MashTun mashTun, Brew brew) { if (paramText.Equals("Mash Tun ready at - Finish")) { MashTunProcessParameters paramToCheck = MashTunProcessParameters.HeatingUpEndTime; MashTunProcessParameters paramToChange = MashTunProcessParameters.MashTunReadyAt; IMashTunState newState = mashTun.IdleState; SetProcessStepEndTime(endTime, mashTun, brew, paramToCheck, paramToChange, newState); } }
public async Task <IActionResult> Create([Bind("BrewID,CreateDate,Name,Description,Style,Yield,OriginalGravity,FinalGravity,ABV")] Brew brew) { if (ModelState.IsValid) { _context.Add(brew); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(brew)); }
public void SetProcessParameterValueTest() { Brew brew = new Brew("01/01/2016", "Maltina", "258"); string paramName = MashCopperProcessParameters.MashingInStartTime.ToString(); brew.SetProcessParameterValue(ProcessEquipment.MashCopper, paramName, "12:00"); string paramValue = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.MashingInStartTime.ToString()); Assert.AreEqual("12:00", paramValue); }
public HoldingVessel(Brew brew) { _brew = brew; _idleState = new HoldingVesselIdleState(); _fillingState = new HoldingVesselFillingState(); //_transferToWcState = new HoldingVesselTransferToWcState(); _rinsingState = new HoldingVesselRinsingState(); _currentState = _idleState; _currentState.InitBrew(this, _brew); }
public void InitBrew(HoldingVessel holdingVessel, Brew brew) { string brewNumber = holdingVessel.Brew.BrewNumber; if (brew != null) { if (brewNumber.Length == 0) { holdingVessel.InitBrew(brew); } } }
public void InitBrew(WortCopper wortCopper, Brew brew) { string brewNumber = wortCopper.Brew.BrewNumber; if (brew != null) { if (brewNumber.Length == 0) { wortCopper.InitBrew(brew); } } }
public void InitBrew(MashTun mashTun, Brew brew) { string brewNumber = mashTun.Brew.BrewNumber; if (brew != null) { if (brewNumber.Length == 0) { mashTun.InitBrew(brew); } } }
public async Task <IActionResult> Put([FromRoute] int id, [FromBody] Brew brew) { try { using (SqlConnection conn = Connection) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = @"UPDATE Brew SET CoffeeDose = @CoffeeDose, WaterDose = @WaterDose, WaterTemp = @WaterTemp, Bloom = @Bloom, BrewTime = @BrewTime, Shared = @Shared, Rating = @Rating, BrewDate = @BrewDate, GrindSetting = @GrindSetting, GrinderId = @GrinderId, Notes = @Notes, BrewMethodId = @BrewMethodId, BeanId = @BeanId, UserId = @UserId WHERE Id = @id"; cmd.Parameters.Add(new SqlParameter("@id", id)); cmd.Parameters.Add(new SqlParameter("@CoffeeDose", brew.CoffeeDose)); cmd.Parameters.Add(new SqlParameter("@WaterDose", brew.WaterDose)); cmd.Parameters.Add(new SqlParameter("@WaterTemp", brew.WaterTemp)); cmd.Parameters.Add(new SqlParameter("@Bloom", brew.Bloom)); cmd.Parameters.Add(new SqlParameter("@BrewTime", brew.BrewTime)); cmd.Parameters.Add(new SqlParameter("@Rating", brew.Rating)); cmd.Parameters.Add(new SqlParameter("@BrewDate", brew.BrewDate)); cmd.Parameters.Add(new SqlParameter("@GrindSetting", brew.GrindSetting)); cmd.Parameters.Add(new SqlParameter("@GrinderId", brew.GrinderId)); cmd.Parameters.Add(new SqlParameter("@Shared", brew.Shared)); cmd.Parameters.Add(new SqlParameter("@Notes", brew.Notes)); cmd.Parameters.Add(new SqlParameter("@BrewMethodId", brew.BrewMethodId)); cmd.Parameters.Add(new SqlParameter("@BeanId", brew.BeanId)); cmd.Parameters.Add(new SqlParameter("@UserId", brew.UserId)); int rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected > 0) { return(new StatusCodeResult(StatusCodes.Status204NoContent)); } throw new Exception("No rows affected"); } } } catch (Exception) { if (!BrewExists(id)) { return(NotFound()); } else { throw; } } }
public async Task <IActionResult> PostBrew([FromBody] Brew brew) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Brews.Add(brew); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBrew", new { id = brew.ID }, brew)); }
public Whirlpool() { _brew = new Brew(); _idleState = new WhirlpoolIdleState(); _castingState = new WhirlpoolCastingState(); _restingState = new WhirlpoolRestingState(); _coolingState = new WhirlpoolCoolingState(); _trubRemovalState = new WhirlpoolTrubRemovalState(); _currentState = _idleState; //_currentState.InitBrew(this, _brew); }
public void InitBrew(MashCopper mashCopper, Brew brew) { string brewNumber = mashCopper.Brew.BrewNumber; if (brew != null) { if (brewNumber.Length == 0) { mashCopper.InitBrew(brew); } } }
public WortCopper() { _brew = new Brew(); _idleState = new WortCopperIdleState(); _heatingState = new WortCopperHeatingState(); _boilingState = new WortCopperBoilingState(); _extraBoilingState = new WortCopperExtraBoilingState(); _castingState = new WortCopperCastingState(); _currentState = _idleState; //_currentState.InitBrew(this, _brew); }
public void InitBrew(Whirlpool whirlpool, Brew brew) { string brewNumber = whirlpool.Brew.BrewNumber; if (brew != null) { if (brewNumber.Length == 0) { whirlpool.InitBrew(brew); } } }
public MashTun() { _brew = new Brew(); _idleState = new MashTunIdleState(); _mashingInState = new MashTunMashingInState(); _proteinRestState = new MashTunProteinRestState(); _sacRestState = new MashTunSacRestState(); _heatingUpState = new MashTunHeatingUpState(); _mashTransferToMashFilterState = new MashTunMashTransferToMashFilterState(); _currentState = _idleState; //_currentState.InitBrew(this, _brew); }