public ActionResult Post([FromBody] LiteWeatherWidgetDTO value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (value == null) { return(BadRequest()); } repoWrapper.WeatherWidget.Insert(mapper.Map <WeatherWidget>(value)); repoWrapper.Save(); return(Ok()); }
public ActionResult Put(long id, [FromBody] LiteWeatherWidgetDTO value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != value.Id) { return(BadRequest("Value with the given id doesn't exist.")); } var entity = repoWrapper.WeatherWidget.Get(id); if (entity == null) { return(BadRequest("Value with the given id is null")); } mapper.Map(value, entity); repoWrapper.Save(); return(Ok()); }