Exemplo n.º 1
0
        public IHttpActionResult UpdateWeather(int id, WeatherInformationDto weatherInformationDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var weatherInformationInDb = _context.WeatherInformations.SingleOrDefault(w => w.Id == id);

            if (weatherInformationInDb == null)
            {
                return(NotFound());
            }
            Mapper.Map(weatherInformationDto, weatherInformationInDb);

            _context.SaveChanges();
            return(Ok());
        }
Exemplo n.º 2
0
        public IHttpActionResult CreateLocationPreference(WeatherInformationDto weatherInformationDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var weather = Mapper.Map <WeatherInformationDto, WeatherInformation>(weatherInformationDto);

            _context.WeatherInformations.Add(weather);
            _context.SaveChanges();


            weatherInformationDto.Id = weather.Id;


            return(Created(new Uri(Request.RequestUri + "/" + weather.Id), weatherInformationDto));
        }