public async Task <ActionResult <WaterHeaterReading> > PostWaterHeaterReadings(IList <WaterHeaterReading> waterheaterData) { WaterHeaterReading whr = new WaterHeaterReading(); foreach (WaterHeaterReading waterheaterDataTemplate in waterheaterData) { waterheaterDataTemplate.WaterHeaterReadingId = Guid.NewGuid().ToString(); _context.WaterHeaterReadings.Add(waterheaterDataTemplate); whr = waterheaterDataTemplate; } await _context.SaveChangesAsync(); return(CreatedAtAction("GetWaterHeaterReading", new { id = whr.WaterHeaterReadingId }, whr)); }
public async Task <ActionResult <WaterHeaterReading> > PutWaterHeaterReading(WaterHeaterReading waterheaterDataTemplate) { if (WaterHeaterReadingExists(waterheaterDataTemplate.WaterHeaterReadingId)) { _context.Entry(waterheaterDataTemplate).State = EntityState.Modified; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(waterheaterDataTemplate); }