public HttpResponseMessage PostMessageThread(MessageThreadPostRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } string UserId = UserService.GetCurrentUserId(); model.UserId = UserId; int threadId = MessageThreadsService.PostMessageThread(model); ItemResponse <int> response = new ItemResponse <int>(); response.Item = threadId; //insert into GroupThreads mapping table GroupThreadsRequest mapping = new GroupThreadsRequest(); mapping.GroupId = model.GroupId; mapping.ThreadId = threadId; MessageThreadsService.PostGroupThreadsMapping(mapping); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public static int PostEventMessageThread(MessageThreadPostRequest model) { int Id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.MessageThreads_Insert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@ThreadTitle", model.ThreadTitle); paramCollection.AddWithValue("@UserId", model.UserId); SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int); p.Direction = System.Data.ParameterDirection.Output; paramCollection.Add(p); }, returnParameters : delegate(SqlParameterCollection param) { int.TryParse(param["@Id"].Value.ToString(), out Id); } ); return(Id); }