/// <summary> /// eventually do this by person id or user account /// </summary> /// <returns></returns> public List<Plant> GetPlants() { BrewDBContext cont = new BrewDBContext(); List<Plant> plants = cont.Plants.ToList(); return plants; }
public List<MasterRecipe> GetMasterRecipeByPlant(int plantID) { BrewDBContext cont = new BrewDBContext(); List<MasterRecipe> recList = cont.Plants.SelectMany(g => g.ThisPlantsBrands).ToList(); return recList; }
public Plant GetPlantByPlantID(int plantID) { BrewDBContext cont = new BrewDBContext(); Plant p = new Plant(); p = cont.Plants.FirstOrDefault(g => g.PlantID == plantID); return p; }
public List<EQControlLoop> GetEQControlLoopsByPlantID(int plantID) { BrewDBContext cont = new BrewDBContext(); List<EQControlLoop> loops = cont.Plants.SelectMany(g => g.PlantLoops).Where(g => g.PlantID == plantID).ToList(); return loops; }
//---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- // Equipment //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- public Plant EQAddPlant(Plant newplant) { BrewDBContext cont = new BrewDBContext(); Plant plant = new Plant(); plant.PlantLoops = new List<EQControlLoop>(); plant.PlantAux = new List<EQAuxilary>(); plant.PlantVessels = new List<EQVessel>(); plant.BrewPubMenu = newplant.BrewPubMenu; plant.PlantAddress = newplant.PlantAddress; plant.PlantLocation = newplant.PlantLocation; plant.PlantName = newplant.PlantName; plant.Units = new List<Unit>(); cont.Plants.Add(plant); cont.SaveChanges(); Plant plantreturn = cont.Plants.FirstOrDefault(e => e.PlantID == plant.PlantID); return plantreturn; }
public List<MasterRecipe> AddMasterRecipeToPlant(int plantID, int masterRecipeID) { BrewDBContext cont = new BrewDBContext(); MasterRecipe rec = cont.MasterRecipes.SingleOrDefault(g => g.MasterRecipeID == masterRecipeID); cont.Plants.SingleOrDefault(g => g.PlantID == plantID).ThisPlantsBrands.Add(rec); cont.SaveChanges(); List<MasterRecipe> recList = cont.Plants.SelectMany(g => g.ThisPlantsBrands).ToList(); return recList; }
//---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- // Plant //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- public List<EQControlLoop> AddEQControlLoopToPlant(int plantID, EQControlLoop loop) { BrewDBContext cont = new BrewDBContext(); Plant plant = cont.Plants.FirstOrDefault(g => g.PlantID == plantID); plant.PlantLoops.Add(loop); cont.Plants.FirstOrDefault(g => g.PlantID == plantID).PlantLoops.Add(loop); cont.SaveChanges(); return cont.EQControlLoops.SelectMany(g => EQControlLoops).Where(g => g.Plant.PlantID == plantID).ToList(); }
/// <summary> /// Test /// </summary> /// <param name="args"></param> static void Main(string[] args) { BrewML b = new BrewML(); BrewDBContext db = new BrewDBContext(); WriteDb Report = new WriteDb(); Plant p = new Plant(); FluentEQType types = new FluentEQType(); types.AddEQType("Pump").Final(); types.AddEQType("Valve").Final(); types.AddEQType("TempController").Final(); Report.reportit(); FluentPlant pd = new FluentPlant(); pd.AddPlant("Little Jakes").Final(); pd.ForPlant("Little Jakes") .HasLoops() .AddControlLoop("WaterPump","Pump") .SetSetPoint(215) .Final(); //Console.WriteLine(pd.GetMessage()); //Console.WriteLine(pd.ForPlant("Little Jakes").HasLoops("WaterInfeed").GetSetPoint()); pd.ForPlant("Little Jakes") .HasLoops() .AddControlLoop("TempControl1", "TempController") .SetSetPoint(222) .Final(); Report.reportit(); //Console.WriteLine(pd.ForPlant("Little Jakes").HasLoops("TempControl1").GetSetPoint()); pd.ForPlant("Little Jakes") .HasLoops("TempControl1") .SetSetPoint(678) .HasType("Valve") .Final(); pd.ForPlant("Little Jakes").HasLoops().ForControlLoop("TempControl1").SetSetPoint(33).Final(); //Console.WriteLine(pd.ForPlant("Little Jakes").HasLoops("TempControl1").GetSetPoint()); pd.AddPlant("Big Jakes").Final(); pd.ForPlant("Big Jakes") .HasLoops() .AddControlLoop("ValveXV1321", "Valve") .SetSetPoint(33) .Final() .HasLoops() .AddControlLoop("DumpValve12", "Valve") .SetSetPoint(123) .Final() .Final(); //Console.WriteLine("-------------------"); pd.ForPlant("Big Jakes") .HasLoops("ValveXV1321") .SetSetPoint(678) .HasType("Valve") .SetSetPoint(99) .Final(); //Console.WriteLine(pd.ForPlant("Big Jakes").HasLoops("ValveXV1321").GetSetPoint()); //Console.WriteLine(pd.ForPlant("Big Jakes").HasLoops("ValveXV1321").GetSetPoint()); Console.WriteLine("-------------------"); Console.WriteLine("Recipe Test "); FluentRecipe rec = new FluentRecipe(); rec.AddRecipe("Big Eddy") .SetBrandDescription("hey this is big stuff") .SetQualityTarget("always high quality") .Final(); rec.ForRecipe("Big Eddy") .HasRecOperations() .AddOperation("Heat 12") .SetSetPoint(33) .Final() .Final(); rec.AddRecipe("So Smooth") .SetQualityTarget("top notch") .HasRecOperations() .AddOperation("Heat Phase 1") .SetSetPoint(170) .Final() .Final(); rec.ForRecipe("So Smooth") .HasRecOperations() .AddOperation("heat phase 2") .SetSetPoint(33) .Final() .HasRecOperations() .AddOperation("Heat Phase 3") .SetSetPoint(34) .Final() .Final(); rec.ForRecipe("So Smooth") .HasRecOperations() .AddOperation("cool phase 3") .SetSetPoint(123) .Final() .HasRecOperations() .AddOperation("cool phase 4") .SetSetPoint(155).Final().Final(); Console.WriteLine("-------------------"); Console.WriteLine("-------------------"); Console.WriteLine("-------------------"); Report.reportit(); Console.WriteLine("hit key"); var name = Console.ReadLine(); }