Exemplo n.º 1
0
        //SP logs individual vote
        public static string VoteInsert(InsertVoteRequest model)
        {
            string userName = "";

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.PointScore_InsertVote"
                                         , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@UserName", model.UserName);
                paramCollection.AddWithValue("@NetVote", model.NetVote);
                paramCollection.AddWithValue("@VoteType", model.VoteType);
                paramCollection.AddWithValue("@ContentId", model.ContentId);
                paramCollection.AddWithValue("@VoterId", model.VoterId);
                paramCollection.AddWithValue("@PlacesId", model.PlacesId);
                paramCollection.AddWithValue("@UserId", model.UserId);
            }, returnParameters : delegate(SqlParameterCollection param)
            {
                userName = (string)param["@UserName"].Value;
            });
            return(userName);
        }
Exemplo n.º 2
0
        public HttpResponseMessage InsertVote(InsertVoteRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            //get current logged-in user
            model.VoterId = UserService.GetCurrentUserId();

            //insert new row into dbo.PointScore, this creates a log for each vote casted
            VoteService.VoteInsert(model);

            //updates overall point score for each username
            _userProfileService.UpdateUserPointScore(model.UserName, model.NetVote);

            //updates the review's individual point score
            if (model.isMedia)
            {
                _RatingService.UpdateReviewPointScoreForMedia(model.ContentId, model.NetVote);
            }
            else
            {
                _RatingService.UpdateReviewPointScore(model.ContentId, model.NetVote);
            }
            SystemEventService.AddSystemEvent(new AddSystemEventModel
            {
                ActorUserId = model.VoterId,
                ActorType   = ActorType.User,
                EventType   = SystemEventType.UserVote,
                TargetId    = model.ContentId,
                TargetType  = TargetType.Review
            });

            return(Request.CreateResponse(HttpStatusCode.OK, model));
        }