public async Task <ActionResult <SolarPvReading> > PostSolarPvReadings(IList <SolarPvReading> solarpvdata) { SolarPvReading spr = new SolarPvReading(); foreach (SolarPvReading batteryDataTemplate in solarpvdata) { batteryDataTemplate.SolarPvReadingId = Guid.NewGuid().ToString(); _context.SolarPvReadings.Add(batteryDataTemplate); spr = batteryDataTemplate; } await _context.SaveChangesAsync(); return(CreatedAtAction("GetSolarPvReading", new { id = spr.SolarPvReadingId }, spr)); }
public async Task <ActionResult <SolarPvReading> > PutSolarPvReadings(SolarPvReading batteryDataTemplate) { if (SolarPvReadingExists(batteryDataTemplate.SolarPvReadingId)) { _context.Entry(batteryDataTemplate).State = EntityState.Modified; } else { return(NotFound()); } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(batteryDataTemplate); }