Ejemplo n.º 1
0
        public async Task <IActionResult> Vote(
            int id,
            int value,
            [FromServices] ISubmissionVoteSink voteSink
            )
        {
            if (value != -1 && value != 1)
            {
                return(BadRequest());
            }

            await voteSink.Submit(new VoteForm
            {
                SubmissionId = id,
                UserId       = UserId,
                Value        = value,
            });

            return(Ok());
        }
        public async Task <IActionResult> UpdateVote(
            int id,
            int value,
            [FromServices] ISubmissionVoteSink voteSink)
        {
            // Doesn't fit in one of the categories of upvote or down vote
            if (value != -1 && value != 1)
            {
                return(BadRequest());
            }

            await voteSink.Submit(new VoteForm
            {
                SubmissionId = id,
                UserId       = UserId,
                Value        = value
            });

            return(Ok());
        }