Ejemplo n.º 1
0
        private BrewLogStep AddStep(BrewLog log, StepDto step)
        {
            var brewStep = new BrewLogStep
            {
                BrewLog = log,
                Order = step.Order,
                Name = step.Name,
                StartTime = DateTime.Now,
                CompleteTime = step.CompleteTime,
                TargetMashTemp = step.TargetMashTemp,
                TargetSpargeTemp = step.TargetSpargeTemp,
                CompleteButtonText = step.CompleteButtonText,
                Instructions = step.Instructions,
                ShowTimer = step.ShowTimer
            };
            _db.Add(brewStep);

            ApplyStepTemperature(brewStep);

            //Add DataCapture values
            var dataCaptureValues = _db.DataCaptureDefinitions.Where(x => x.BrewStepTemplateId == step.Order);
            foreach (var v in dataCaptureValues)
            {
                if (v.ValueType == "float")
                {
                    _db.Add(new DataCaptureFloatValue
                    {
                        BrewLogStep = brewStep,
                        Label = v.Label,
                        Optional = v.Optional,
                        Units = v.Units
                    });
                }
                else if (v.ValueType == "int")
                {
                    _db.Add(new DataCaptureIntValue
                    {
                        BrewLogStep = brewStep,
                        Label = v.Label,
                        Optional = v.Optional,
                        Units = v.Units
                    });
                }
                else if (v.ValueType == "string")
                {
                    _db.Add(new DataCaptureStringValue
                    {
                        BrewLogStep = brewStep,
                        Label = v.Label,
                        Optional = v.Optional,
                        Units = v.Units
                    });
                }
            }

            return brewStep;
        }
Ejemplo n.º 2
0
        public BrewLogStep InitializeNewBrew(SetupDto value)
        {
            var l = new BrewLog
            {
                TimeStamp = DateTime.Now,
                Name = value.Name,
                MashTemp = value.MashTemp,
                StrikeTemp = value.StrikeTemp,
                SpargeTemp = value.SpargeTemp,
                MashOutTemp = value.MashOutTemp,
                MashTimeInMinutes = value.MashTimeInMinutes,
                BoilTimeInMinutes = value.BoilTimeInMinutes,
                BatchSize = value.BatchSize,
                MashWaterAmount = value.MashWaterAmount,
                SpargeWaterAmount = value.SpargeWaterAmount
            };
            _db.Add(l);

            var firstStep = GetFirstStep(l);

            var brewStep = AddStep(l, firstStep);

            return brewStep;
        }
Ejemplo n.º 3
0
 private float ResolveTemp(BrewLog brewLog, string placeHolder)
 {
     if (placeHolder == "strikeTemp")
     {
         return brewLog.StrikeTemp;
     }
     if (placeHolder == "spargeTemp")
     {
         return brewLog.SpargeTemp;
     }
     if (placeHolder == "mashTemp")
     {
         return brewLog.MashTemp;
     }
     if (placeHolder == "mashOutTemp")
     {
         return brewLog.MashOutTemp;
     }
     return 0;
 }
Ejemplo n.º 4
0
 private DateTime? ResolveCompleteTime(BrewLog brewLog, string placeHolder)
 {
     if (placeHolder == "mashTimeInMinutes")
     {
         return DateTime.Now.AddMinutes(brewLog.MashTimeInMinutes);
     }
     if (placeHolder == "boilTimeInMinutes")
     {
         return DateTime.Now.AddMinutes(brewLog.BoilTimeInMinutes);
     }
     return null;
 }
Ejemplo n.º 5
0
        private StepDto GetStepDto(BrewStepTemplate template, BrewLog brewLog)
        {
            return new StepDto
            {
                Order = template.Id,
                Name = template.Name,
                StartTime = DateTime.Now,
                CompleteButtonText = template.CompleteButtonText,
                Instructions = template.Instructions,
                CompleteTime = ResolveCompleteTime(brewLog, template.CompleteTimeAdd),
                TargetMashTemp = ResolveTemp(brewLog, template.Target1TempFrom),
                TargetSpargeTemp = ResolveTemp(brewLog, template.Target2TempFrom),
                ShowTimer = template.ShowTimer
            };

        }
Ejemplo n.º 6
0
 private StepDto GetFirstStep(BrewLog brewLog)
 {
     return GetStepDto(_db.BrewStepTemplates.OrderBy(x => x.Id).First(), brewLog);
 }