public int InsertFollow(FollowersRequestModel model) { int uid = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.Followers_Insert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@FollowerId", UserService.GetCurrentUserId()); paramCollection.AddWithValue("@FollowedId", model.FollowedId); 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 uid); }); SystemEventRequestModel se = new SystemEventRequestModel(); se.ActorUserId = UserService.GetCurrentUserId(); se.EventType = Enums.SystemEventType.Followed; se.TargetUserId = model.FollowedId.ToString(); _SystemEventService.Insert(se); return(uid); }
public HttpResponseMessage FollowUser(FollowersRequestModel model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); response.Item = _FollowerService.InsertFollow(model); return(Request.CreateResponse(response)); }