예제 #1
0
        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));
        }
예제 #2
0
        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);
        }