public HttpResponseMessage PostEventMessageThread(MessageThreadPostRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } string UserId = UserService.GetCurrentUserId(); //Guid myId = new Guid(UserId); model.UserId = UserId; int threadId = MessageThreadsService.PostEventMessageThread(model); ItemResponse <int> response = new ItemResponse <int>(); response.Item = threadId; //insert into EventThreads mapping table EventThreadsRequest mapping = new EventThreadsRequest(); //for inserting into mapping table mapping.EventId = model.EventId; mapping.ThreadId = threadId; MessageThreadsService.PostEventThreadsMapping(mapping); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public static int PostEventThreadsMapping(EventThreadsRequest model) { int Id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.EventThreads_Insert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@EventId", model.EventId); paramCollection.AddWithValue("@ThreadId", model.ThreadId); 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); }