Beispiel #1
0
        private BrewLogStep AddStep(BrewLog log, StepDto step)
        {
            var brewStep = new BrewLogStep
            {
                BrewLog = log,
                Order = step.Order,
                Name = step.Name,
                StartTime = DateTime.UtcNow,
                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;
        }
Beispiel #2
0
        public BrewLogStep InitializeNewBrew(SetupDto value)
        {
            var l = new BrewLog
            {
                Initiated = DateTime.UtcNow,
                BeginMash = value.BeginMash.ToUniversalTime(),
                BatchNumber = value.BatchNumber,
                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;
        }
Beispiel #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;
 }
Beispiel #4
0
 private DateTime? ResolveCompleteTime(BrewLog brewLog, string placeHolder)
 {
     if (placeHolder == "mashTimeInMinutes")
     {
         return DateTime.UtcNow.AddMinutes(brewLog.MashTimeInMinutes);
     }
     if (placeHolder == "boilTimeInMinutes")
     {
         return DateTime.UtcNow.AddMinutes(brewLog.BoilTimeInMinutes);
     }
     return null;
 }
Beispiel #5
0
        private StepDto GetStepDto(BrewStepTemplate template, BrewLog brewLog)
        {
            return new StepDto
            {
                Order = template.Id,
                Name = template.Name,
                StartTime = DateTime.UtcNow,
                CompleteButtonText = template.CompleteButtonText,
                Instructions = template.Instructions,
                CompleteTime = ResolveCompleteTime(brewLog, template.CompleteTimeAdd),
                TargetMashTemp = ResolveTemp(brewLog, template.Target1TempFrom),
                TargetSpargeTemp = ResolveTemp(brewLog, template.Target2TempFrom),
                ShowTimer = template.ShowTimer
            };

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