public async Task <IActionResult> EditMatch(int matchId, EditMatchBindingModel model)
        {
            var result = await _matchService.EditMatchAsync(matchId, model);

            if (result.ErrorOccurred)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }
        public async Task <ResponseDto <BaseModelDto> > EditMatchAsync(int matchId, EditMatchBindingModel model)
        {
            var response = new ResponseDto <BaseModelDto>();

            var match = _matchRepository.GetById(matchId);

            if (match == null)
            {
                response.Errors.Add(ServiceErrors.MATCH_DOES_NOT_EXIST);
                return(response);
            }



            var statisticsToDelete = new List <Statistic>();

            foreach (var matchPlayer in match.MatchPlayers)
            {
                foreach (var stat in matchPlayer.Statistics)
                {
                    statisticsToDelete.Add(stat);
                }
            }

            for (var i = statisticsToDelete.Count - 1; i >= 0; i--)
            {
                await _statisticRepository.DeleteAsync(statisticsToDelete[i]);
            }

            match.Date      = model.Date;
            match.HostScore = model.HostScore;
            match.AwayScore = model.AwayScore;

            await _matchRepository.EditAsync(match);



            return(response);
        }