Esempio n. 1
0
        public async Task <string> GenerateFightsDraws(int contestId, int categoryId)
        {
            var acceptedFighterRequests = await _contestRequestRepository.GetContestAcceptedFighterRequests(contestId, categoryId);

            var fighters = acceptedFighterRequests.Select(r => r.User).ToList();
            var category = await _contestCategoriesRepository.Get(categoryId);

            FightsTree fightsTree = new FightsTree(contestId: contestId, contestCategoryId: categoryId,
                                                   fightStructureId: category.FightStructureId, fighterCount: fighters.Count);

            _fightersTossupper.Tossup(fighters, fightsTree);

            var fights = fightsTree.ToList();

            await _fightsRepository.SaveFights(fights);

            _fightsDiagramBuilder.GenerateFightDiagram(fights);
            string fightsDrawsJson = _fightsDiagramBuilder.ToJson();

            return(fightsDrawsJson);
        }
        public async Task <List <FightResponseModel> > BuildFights(int contestId, int categoryId)
        {
            var acceptedFighterRequests = await _contestRequestRepository.GetContestAcceptedFighterRequests(contestId, categoryId);

            var fighters = acceptedFighterRequests.Select(r => r.User).ToList();
            var category = await _contestCategoriesRepository.Get(categoryId);

            FightsTree fightsTree = new FightsTree(contestId: contestId, contestCategoryId: categoryId,
                                                   fightStructureId: category.FightStructureId, fighterCount: fighters.Count);

            _fightersTossupper.Tossup(fighters, fightsTree);

            var fights      = fightsTree.ToList();
            var savedFights = await Save(fights);

            return(savedFights);
        }
        public async Task <ContestCategoryModel> GetCategory(int id)
        {
            var category = await _repository.Get(id);

            return(_mapper.Map <ContestCategoryModel>(category));
        }