public IHttpActionResult Post(ChatAddRequest model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ItemResponse <int> response = new ItemResponse <int> { Item = _chatService.Insert(model) }; return(Ok(response)); } catch (Exception ex) { int currentUser = _userService.GetCurrentUserId(); _appLogService.Insert(new AppLogAddRequest { AppLogTypeId = 1, Message = ex.Message, StackTrace = ex.StackTrace, Title = "Error in " + GetType().Name + " " + System.Reflection.MethodBase.GetCurrentMethod().Name, UserBaseId = currentUser }); return(BadRequest(ex.Message)); } }
public HttpResponseMessage Post(ChatAddRequest model) { try { ItemResponse <int> response = new ItemResponse <int>(); response.Item = _chatService.Insert(model); return(Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception ex) { throw ex; } }
public int Insert(ChatAddRequest model) { int id = 0; DataProvider.ExecuteNonQuery("dbo.Chat_Insert", inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@ChatName", model.ChatName); paramCollection.AddWithValue("@TeamId", model.TeamId); SqlParameter idOutput = new SqlParameter("@Id", SqlDbType.Int); idOutput.Direction = ParameterDirection.Output; paramCollection.Add(idOutput); }, returnParameters : delegate(SqlParameterCollection paramCollection) { int.TryParse(paramCollection["@Id"].Value.ToString(), out id); }); return(id); }
public int Insert(ChatAddRequest model) { int returnValue = 0; DataProvider.ExecuteNonQuery("dbo.Chat_Insert", inputParamMapper: (SqlParameterCollection inputs) => { inputs.AddWithValue("@ChatTitle", model.ChatTitle); SqlParameter idOut = new SqlParameter("@Id", 0); idOut.Direction = ParameterDirection.Output; inputs.Add(idOut); }, returnParameters: (SqlParameterCollection inputs) => { int.TryParse(inputs["@Id"].Value.ToString(), out returnValue); }); return(returnValue); }