Ejemplo n.º 1
0
        public async Task <ActionResult <Climates> > PostClimates(ClimatesDto climate)
        {   //Create a new climate and give it the information from the provided DTO
            Climates newClimate = new Climates();

            newClimate.Climate = climate.info;

            _context.Climates.Add(newClimate);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetClimates", new { id = newClimate.ClimateID }, newClimate));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutClimates(int id, ClimatesDto climate)
        {   //Update climate based on the id, and DTO provided
            var result = await _context.Climates.SingleOrDefaultAsync(c => c.ClimateID == id);

            if (result != null)
            {
                result.Climate = climate.info;
                await _context.SaveChangesAsync();

                return(Ok());
            }

            return(NotFound());
        }