示例#1
0
        private async Task <IActionResult> UpdateManualCriticScore(Guid publisherID, Guid publisherGameID, decimal?manualCriticScore)
        {
            var systemWideSettings = await _interLeagueService.GetSystemWideSettings();

            if (systemWideSettings.BidProcessingMode)
            {
                return(BadRequest());
            }

            var currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var publisher = await _publisherService.GetPublisher(publisherID);

            if (publisher.HasNoValue)
            {
                return(BadRequest());
            }

            var league = await _fantasyCriticService.GetLeagueByID(publisher.Value.LeagueYear.League.LeagueID);

            if (league.HasNoValue)
            {
                return(BadRequest());
            }

            if (league.Value.LeagueManager.UserID != currentUser.UserID)
            {
                return(Forbid());
            }

            Maybe <PublisherGame> publisherGame = await _publisherService.GetPublisherGame(publisherGameID);

            if (publisherGame.HasNoValue)
            {
                return(BadRequest());
            }

            var leagueYear = await _fantasyCriticService.GetLeagueYear(league.Value.LeagueID, publisher.Value.LeagueYear.Year);

            if (leagueYear.HasNoValue)
            {
                return(BadRequest());
            }

            await _fantasyCriticService.ManuallyScoreGame(publisherGame.Value, manualCriticScore);

            await _fantasyCriticService.UpdateFantasyPoints(leagueYear.Value);

            return(Ok());
        }