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) } }; }
public async Task<IEnumerable<DataCaptureValueDto>> GetDefinedDataCaptureValues(int brewId) { using (var db = new BrewMaticContext()) { var repo = new BrewLogRepository(db); return await repo.GetDefinedDataCaptureValues(brewId); } }
public IEnumerable<BrewLogsDto> Get() { using (var db = new BrewMaticContext()) { var repo = new BrewLogRepository(db); return repo.ListBrewLogs().ToList(); } }
public async Task<IEnumerable<BrewLogHistoryDto>> GetBrewHistory(int brewId) { using (var db = new BrewMaticContext()) { var repo = new BrewLogRepository(db); return await repo.GetBrewHistory(brewId); } }
public async Task<CurrentBrewDto> Get(int brewId) { using (var db = new BrewMaticContext()) { var repo = new BrewLogRepository(db); return await repo.GetBrewDto(brewId); } }
public void Save([FromBody]DataCaptureValueDto[] values) { using (var db = new BrewMaticContext()) { var repo = new BrewLogRepository(db); repo.SaveDataCaptureValues(values); db.SaveChanges(); } }
public void GoToPreviousStep([FromBody]int brewId) { using (var db = new BrewMaticContext()) { var repo = new BrewLogRepository(db); repo.GoBackOneStep(brewId); db.SaveChanges(); } }
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; } }