示例#1
0
        public async Task <IActionResult> UpdateMatchScores(Guid scheduleId, string homeTeam, int homeScore, string awayTeam, int awayScore)
        {
            try
            {
                var view = new ScheduleView
                {
                    ScheduleId    = scheduleId,
                    HomeTeamScore = homeScore,
                    AwayTeamScore = awayScore
                };
                var homeRosterResultTask = _rosterService.AddToTeamScoreAsync(homeTeam, homeScore, awayScore);
                var awayRosterResultTask = _rosterService.AddToTeamScoreAsync(awayTeam, awayScore, homeScore);
                var scheduleResultTask   = _scheduleService.UpdateScheduleAsync(view);
                var result = await homeRosterResultTask && await awayRosterResultTask && await scheduleResultTask;
                if (!result)
                {
                    throw new Exception();
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Error setting match scores for {scheduleId}.");
            }

            return(RedirectToAction("Index"));
        }