public int UpdateThread(ThreadUpdateRequest model, string userId) { int id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.ForumThreads_UpdateById" , inputParamMapper: delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Id", model.Id); paramCollection.AddWithValue("@Title", model.Title); paramCollection.AddWithValue("@Content", model.Content); paramCollection.AddWithValue("@UserId", userId); } , returnParameters: delegate(SqlParameterCollection param) { int.TryParse(param["@Id"].Value.ToString(), out id); } ); return id; }
public HttpResponseMessage UpdateThread(ThreadUpdateRequest model) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } SuccessResponse response = new SuccessResponse(); string userId = _userService.GetCurrentUserId(); try { _forumService.UpdateThread(model, userId); } catch (Exception ex) { throw ex; } return Request.CreateResponse(response); }