Ejemplo n.º 1
0
        public async Task<BrewMaticNewSettings> Post([FromBody]BrewMaticStatus value)
        {
            _logger.LogDebug($"{DateTime.Now}: Temp1: {value.Temp1}. Temp2: {value.Temp2}. Heater1: {value.Heater1Percentage}%. Heater2: {value.Heater2Percentage}%");

            BrewTargetTemperature t;

            using (var db = new BrewMaticContext())
            {
                var repo = new BrewLogRepository(db);
                t = repo.GetTargetTemp();
                db.TempLogs.Add(new BrewTempLog { Temp1 = value.Temp1, Temp2 = value.Temp2, Heater1Percentage = value.Heater1Percentage, Heater2Percentage = value.Heater2Percentage, TimeStamp = DateTime.Now });
                var count = await db.SaveChangesAsync();
                _logger.LogDebug("{0} records saved to database", count);
            }

            return new BrewMaticNewSettings
            {
                TargetTemp1 = t.Target1,
                TargetTemp2 = t.Target2,
                ScreenContent = new[]
                {
                    "Hello! " + DateTime.UtcNow.AddHours(2).ToString("HH:mm:ss"),
                    "",
                    GetLineString("1", value.Temp1, t.Target1, value.Heater1Percentage),
                    GetLineString("2", value.Temp2, t.Target2, value.Heater2Percentage)
                }
            };
        }
Ejemplo n.º 2
0
 public async Task<IEnumerable<DataCaptureValueDto>> GetDefinedDataCaptureValues(int brewId)
 {
     using (var db = new BrewMaticContext())
     {
         var repo = new BrewLogRepository(db);
         return await repo.GetDefinedDataCaptureValues(brewId);
     }
 }
Ejemplo n.º 3
0
 public IEnumerable<BrewLogsDto> Get()
 {
     using (var db = new BrewMaticContext())
     {
         var repo = new BrewLogRepository(db);
         return repo.ListBrewLogs().ToList();
     }
 }
Ejemplo n.º 4
0
 public async Task<IEnumerable<BrewLogHistoryDto>> GetBrewHistory(int brewId)
 {
     using (var db = new BrewMaticContext())
     {
         var repo = new BrewLogRepository(db);
         return await repo.GetBrewHistory(brewId);
     }
 }
Ejemplo n.º 5
0
 public async Task<CurrentBrewDto> Get(int brewId)
 {
     using (var db = new BrewMaticContext())
     {
         var repo = new BrewLogRepository(db);
         return await repo.GetBrewDto(brewId);
     }
 }
Ejemplo n.º 6
0
 public void Save([FromBody]DataCaptureValueDto[] values)
 {
     using (var db = new BrewMaticContext())
     {
         var repo = new BrewLogRepository(db);
         repo.SaveDataCaptureValues(values);
         db.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 public void GoToPreviousStep([FromBody]int brewId)
 {
     using (var db = new BrewMaticContext())
     {
         var repo = new BrewLogRepository(db);
         repo.GoBackOneStep(brewId);
         db.SaveChanges();
     }
 }
Ejemplo n.º 8
0
        public async Task<int> StartNewBrew([FromBody]SetupDto value)
        {
            using (var db = new BrewMaticContext())
            {
                var repo = new BrewLogRepository(db);

                var brewStep = repo.InitializeNewBrew(value);

                await db.SaveChangesAsync();
                return brewStep.BrewLog.Id;
            }
        }