예제 #1
0
        public ActionResult PostEpisodeVote([FromRoute] int episodeID, [FromBody] Vote vote)
        {
            var episode = RepoFactory.AnimeEpisode.GetByID(episodeID);

            if (episode == null)
            {
                return(NotFound(EpisodeNotFoundWithEpisodeID));
            }

            if (vote.Value < 0)
            {
                return(BadRequest("Value must be greater than or equal to 0."));
            }
            if (vote.Value > vote.MaxValue)
            {
                return(BadRequest($"Value must be less than or equal to the set max value ({vote.MaxValue})."));
            }
            if (vote.MaxValue <= 0)
            {
                return(BadRequest("Max value must be an integer above 0."));
            }

            Episode.AddEpisodeVote(HttpContext, episode, User.JMMUserID, vote);

            return(NoContent());
        }