Esempio n. 1
0
        public async Task <IListModelResponse <MatchListItemDto> > EditRoundScheduleAsync(int leagueId, byte roundNum, IEnumerable <Match> matches)
        {
            Logger?.LogInformation($"{nameof(EditRoundScheduleAsync)} has been invoked");

            var response = new ListModelResponse <MatchListItemDto>();

            try
            {
                var league = await GetAndValidateItem(leagueId, roundNum);

                var oldScheduleMatches = MatchRepository.GetItems().Where(m => m.LeagueId == leagueId && m.Round == roundNum);
                await MatchRepository.RemoveItemsAsync(oldScheduleMatches);

                await MatchRepository.AddItemsAsync(matches);

                response.Model = matches.Select(item => Mapper.Map <MatchListItemDto>(item)).ToList();
            }
            catch (Exception ex)
            {
                response.SetError(ex, Logger);
            }

            return(response);
        }