public IHttpActionResult Post(TimelineFeedAddRequest model) { try { model.CreatedById = _authenticationService.GetCurrentUserId(); //this grabs the logged in user's id (for new posts) if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ItemResponse <int> response = new ItemResponse <int> { Item = _timelineFeedService.Post(model) }; return(Ok(response)); } catch (Exception ex) { _errorLogService.Post(new ErrorLogAddRequest { ErrorSourceTypeId = 1, Message = ex.Message, StackTrace = ex.StackTrace, Title = "Error in " + GetType().Name + " " + System.Reflection.MethodBase.GetCurrentMethod().Name }); return(BadRequest(ex.Message)); } }
public int Post(TimelineFeedAddRequest model) { int id = 0; DataProvider.ExecuteNonQuery("dbo.Timelines_TimelineFeed_Insert", inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@TimelineFeedTypeId", model.TimelineFeedTypeId); paramCollection.AddWithValue("@FeedContent", model.FeedContent); paramCollection.AddWithValue("@IsPublic", model.IsPublic); paramCollection.AddWithValue("@IsSubscriptionOnly", model.IsSubscriptionOnly); paramCollection.AddWithValue("@IsArchived", model.IsArchived); paramCollection.AddWithValue("@CreatedById", model.CreatedById); //paramCollection.AddWithValue("@ModifiedById", model.CreatedById); SqlParameter paramId = new SqlParameter("@Id", SqlDbType.Int); paramId.Direction = ParameterDirection.Output; paramId.Value = id; paramCollection.Add(paramId); }, returnParameters: (SqlParameterCollection paramCollection) => { int.TryParse(paramCollection["@Id"].Value.ToString(), out id); }); return(id); }