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 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 }); }
public static Tuple <List <TurnamentPlayOff>, List <List <PositionCommand> > > Execute(Guid turnamentId, bool isAdmin) { var circle = DbHelper.GetCircleForTurnament(turnamentId); circle.Sort((a, b) => a.numbr_circle <= b.numbr_circle ? -1 : 1); var turnamentPlayOff = new List <TurnamentPlayOff>(); var positionPlayOff = new List <List <PositionCommand> >(); if (circle != null) { circle.ForEach(x => { turnamentPlayOff.Add(new TurnamentPlayOff { PlayOffId = x.id_circle_for_turnament.ToString(), NumberCircle = x.numbr_circle, StateCode = x.state_code, GroupTourNumber = GetGroupTourNumberBLL.Execute(x.id_circle_for_turnament, isAdmin) }); var position = DbHelper.GetPositionCommand(x.id_circle_for_turnament); var pos = new List <PositionCommand>(); position.ForEach(p => { pos.Add(new PositionCommand { CommandId = p.id_account.ToString(), CommandName = p.command_name, Points = p.points, Position = p.position, Place = p.place }); }); positionPlayOff.Add(pos); }); } return(new Tuple <List <TurnamentPlayOff>, List <List <PositionCommand> > >(turnamentPlayOff, positionPlayOff)); }
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); }