public int Add(QAndAAddRequest model, string UserID) { int ID = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.QAndA_Insert", inputParamMapper: (Action<SqlParameterCollection>)delegate (SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Question", model.Question); paramCollection.AddWithValue("@Answer", model.Answer); paramCollection.AddWithValue("@Type", model.Type); paramCollection.AddWithValue("@UserID", UserID); SqlParameter b = new SqlParameter("@ID", System.Data.SqlDbType.Int); b.Direction = System.Data.ParameterDirection.Output; paramCollection.Add(b); }, returnParameters: delegate (SqlParameterCollection param) { int.TryParse(param["@ID"].Value.ToString(), out ID); } ); return ID; }
public HttpResponseMessage AddQAndA(QAndAAddRequest model) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } string userId = _userService.GetCurrentUserId(); ItemResponse<Int32> response = new ItemResponse<Int32>(); response.Item = _qAndAService.Add(model, userId); return Request.CreateResponse(response); }