public static GetCircleTurnamentResponse Execute(ElementRequest request)
        {
            var turnamentId          = Guid.Parse(request.Txt);
            var turnament            = DbHelper.GetTurnament(turnamentId);
            var commands             = DbHelper.GetCommandForTurnament(turnamentId, true);
            var commandsForTurnament = new List <CommandForTurnament>();

            foreach (var command in commands)
            {
                var commandForTurnament = new CommandForTurnament
                {
                    Id     = command.Id,
                    Name   = command.Name,
                    Status = command.Status
                };

                commandsForTurnament.Add(commandForTurnament);
            }

            var positionCommands = turnament.step > 1 ? GetPositionCommandBLL.Execute(turnamentId) : new List <PositionCommand>();
            var groupTourNumber  = turnament.step > 1 ? GetGroupTourNumberBLL.Execute(turnamentId, true) : new List <GroupTourNumber>();

            var item = new CircleTurnamentAdmin
            {
                Id                     = turnament.id_turnament.ToString(),
                Name                   = turnament.name,
                DateStart              = turnament.date_start,
                DateEnd                = turnament.date_end,
                Type                   = turnament.type,
                StateCode              = turnament.state_code,
                Step                   = turnament.step,
                Description            = turnament.description,
                ContributionGame       = turnament.сontribution_game,
                ContributionTournament = turnament.сontribution_tournament,
                Commands               = commandsForTurnament,
                PositionCommand        = positionCommands,
                GroupTourNumber        = groupTourNumber
            };

            return(new GetCircleTurnamentResponse {
                Turnament = item
            });
        }
Esempio n. 2
0
        public static List <TurnamentGroups> Execute(Guid turnamentId, bool isAdmin)
        {
            var response = new List <TurnamentGroups>();

            var turnamentGroup = DbHelper.GetTurnamentGroups(turnamentId);

            turnamentGroup.ForEach(x => {
                var positionCommands = GetPositionCommandBLL.Execute(x.id_group_for_turnament);
                var groupTourNumber  = GetGroupTourNumberBLL.Execute(x.id_group_for_turnament, isAdmin);

                response.Add(new TurnamentGroups {
                    GroupId         = x.id_group_for_turnament.ToString(),
                    PositionCommand = positionCommands,
                    GroupTourNumber = groupTourNumber
                });
            });

            return(response);
        }
        public static GetTurnamentsForUserResponse Execute(string accountId)
        {
            var turnaments = DbHelper.GetTurnamentsForUser(Guid.Parse(accountId));

            var response = new GetTurnamentsForUserResponse {
                Turnaments = new List <Turnament>()
            };

            foreach (var item in turnaments)
            {
                var positionCommands = item.type == 1 ? GetPositionCommandBLL.Execute(item.id_turnament) : new List <PositionCommand>();
                var groupTourNumber  = item.type == 1 ? GetGroupTourNumberBLL.Execute(item.id_turnament, false) : new List <GroupTourNumber>();
                var turnamentGroups  = item.type == 2 ? GetTurnamentGroupsBLL.Execute(item.id_turnament, false) : new List <TurnamentGroups>();
                var turnamentPlayOff = new List <TurnamentPlayOff>();
                var positionPlayOff  = new List <List <PositionCommand> >();

                if (item.type == 2)
                {
                    var tuple = GetPositionPlayOffBLL.Execute(item.id_turnament, false);
                    turnamentPlayOff = tuple.Item1;
                    positionPlayOff  = tuple.Item2;
                }

                var commands             = DbHelper.GetCommandForTurnament(item.id_turnament, true);
                var commandsForTurnament = new List <CommandForTurnament>();

                foreach (var command in commands)
                {
                    var commandForTurnament = new CommandForTurnament
                    {
                        Name   = command.Name,
                        Status = command.Status
                    };

                    commandsForTurnament.Add(commandForTurnament);
                }

                groupTourNumber.Sort((a, b) => a.NumberTour <= b.NumberTour ? -1 : 1);

                var turnament = new Turnament
                {
                    Id = item.id_turnament.ToString(),
                    ContributionGame       = item.сontribution_game,
                    ContributionTournament = item.сontribution_tournament,
                    DateEnd          = item.date_end == null ? null : item.date_end.Value.ToShortDateString(),
                    DateStart        = item.date_start == null ? null : item.date_start.Value.ToShortDateString(),
                    Description      = item.description,
                    Name             = item.name,
                    Commands         = commandsForTurnament,
                    Type             = item.type,
                    PositionCommand  = positionCommands,
                    GroupTourNumber  = groupTourNumber,
                    TurnamentGroups  = turnamentGroups,
                    TurnamentPlayOff = turnamentPlayOff,
                    PositionPlayOff  = positionPlayOff
                };

                response.Turnaments.Add(turnament);
            }
            ;

            return(response);
        }