public void UpdatePost(PostsUpdateRequest req) { dataProvider.ExecuteNonQuery( "Posts_Update", inputParamMapper: (parameters) => { parameters.AddWithValue("@Id", req.Id); parameters.AddWithValue("@Location", req.Location); parameters.AddWithValue("@Lat", req.Lat); parameters.AddWithValue("@Long", req.Long); parameters.AddWithValue("@EventDate", req.EventDate); parameters.AddWithValue("@PostText", req.PostText); parameters.AddWithValue("@PostItemsJSON", req.PostItemsJSON); }); }
public HttpResponseMessage UpdatePost(PostsUpdateRequest req, int id) { if (req == null) { ModelState.AddModelError("", "You did not add any body data!"); } if (req.Id != id) { ModelState.AddModelError("Id", "Id in the URL does not match the Id in the body."); } if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } postsService.UpdatePost(req); return(Request.CreateResponse(HttpStatusCode.OK, new SuccessResponse())); }