public int Insert(InfluencerAddRequest influencer, int userId) { int newInfluencerId = 0; _dataProvider.ExecuteNonQuery("dbo.Influencer_Insert", (param) => { param.AddWithValue("@UserId", userId); if (influencer.Bio == null) { param.AddWithValue("@Bio", ""); } else { param.AddWithValue("@Bio", influencer.Bio); } param.AddWithValue("@FaqId", influencer.FaqId); param.AddWithValue("@MilestoneId", influencer.MilestoneId); param.AddWithValue("@Account", influencer.Account); param.AddWithValue("@Id", SqlDbType.Int).Direction = ParameterDirection.Output; }, (param) => { Int32.TryParse(param["@Id"].Value.ToString(), out newInfluencerId); } ); return(newInfluencerId); }
public ActionResult <ItemResponse <Influencer> > Insert(InfluencerAddRequest influencer) { ItemResponse <int> response = null; ActionResult result = null; int currentUserId = _authService.GetCurrentUserId(); try { int newId = _influencerService.Insert(influencer, currentUserId); if (newId > 0) { response = new ItemResponse <int>(); response.Item = newId; result = Created201(response); } else { result = NotFound404(new ErrorResponse("You must be logged in to use this feature.")); } } catch (Exception ex) { Logger.LogError(ex.ToString()); result = StatusCode(500, "Internal Server Error"); } return(result); }