Esempio n. 1
0
        public async Task <string> GetBlockNames(
            int tournamentId,
            string tennisEventId,
            [FromQuery(Name = "participationClassificationId")] int?participationClassificationId)
        {
            var dto = new DrawTableRepositoryDto(tournamentId, tennisEventId)
            {
                IncludeBlocks = true,
                IncludeGames  = true,
            };
            var drawTable = await this.drawTableUseCase.GetDrawTable(dto);

            var participationClassification = participationClassificationId.HasValue
                ? Enumeration.FromValue <ParticipationClassification>(participationClassificationId.Value)
                : null;
            var blocks = drawTable.Blocks.GetIniitalizedBlocks(participationClassification);

            if (!blocks.Any())
            {
                return("[]");
            }

            var json = blocks.Select(o => new
            {
                blockNumber = o.BlockNumber?.Value,
                name        = o.DisplayValue,
                participationClassificationId = o.ParticipationClassification.Id,
            });

            return(JsonSerializer.Serialize(json));
        }
Esempio n. 2
0
        public async Task <HttpResponseMessage> RegisterEntryDetails(int tournamentId, string tennisEventId, [FromBody] JsonElement json)
        {
            try
            {
                var entryDetails = json.EnumerateArray().Select(o =>
                {
                    var entryNumber = new EntryNumber(JsonConverter.ToInt32(o.GetProperty("entryNumber")));
                    var participationClassification = JsonConverter.ToEnumeration <ParticipationClassification>(o.GetProperty("participationClassificationId"));
                    var seedNumber           = new SeedNumber(JsonConverter.ToInt32(o.GetProperty("seedNumber")));
                    var teamCodes            = o.GetProperty("teamCodes").EnumerateArray().Select(p => new TeamCode(JsonConverter.ToString(p)));
                    var teamNames            = o.GetProperty("teamNames").EnumerateArray().Select(p => new TeamName(JsonConverter.ToString(p)));
                    var teamAbbreviatedNames = o.GetProperty("teamAbbreviatedNames").EnumerateArray().Select(p => new TeamAbbreviatedName(JsonConverter.ToString(p)));
                    var playerCodes          = o.GetProperty("playerCodes").EnumerateArray().Select(p => new PlayerCode(JsonConverter.ToString(p)));
                    var playerFamilyNames    = o.GetProperty("playerFamilyNames").EnumerateArray().Select(p => new PlayerFamilyName(JsonConverter.ToString(p)));
                    var playerFirstNames     = o.GetProperty("playerFirstNames").EnumerateArray().Select(p => new PlayerFirstName(JsonConverter.ToString(p)));
                    var points = o.GetProperty("points").EnumerateArray().Select(p => new Point(JsonConverter.ToInt32(p)));
                    var canParticipationDates = o.GetProperty("canParticipationDates").EnumerateArray()
                                                .Where(p => JsonConverter.ToBoolean(p.GetProperty("isParticipate")))
                                                .Select(p => new CanParticipationDate(JsonConverter.ToDateTime(p.GetProperty("value"))));
                    var receiptStatus = JsonConverter.ToEnumeration <ReceiptStatus>(o.GetProperty("receiptStatusId"));

                    var entryPlayers = teamCodes.Select((o, i) => new EntryPlayer(
                                                            o,
                                                            teamNames.ElementAt(i),
                                                            teamAbbreviatedNames.ElementAt(i),
                                                            playerCodes.ElementAt(i),
                                                            playerFamilyNames.ElementAt(i),
                                                            playerFirstNames.ElementAt(i),
                                                            points.ElementAt(i)
                                                            ));

                    return(new EntryDetail(
                               entryNumber,
                               participationClassification,
                               seedNumber,
                               entryPlayers,
                               canParticipationDates,
                               receiptStatus,
                               UsageFeatures.DrawTable));
                });

                var dto = new DrawTableRepositoryDto(tournamentId, tennisEventId)
                {
                    IncludeEntryDetails           = true,
                    IncludeQualifyingDrawSettings = true,
                    IncludeMainDrawSettings       = true,
                };
                var drawTable = await this.drawTableUseCase.GetDrawTable(dto);

                drawTable.UpdateEntryDetails(entryDetails);
                await this.drawTableUseCase.UpdateDrawTable(drawTable);
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Esempio n. 3
0
        public async Task <ActionResult> Players(PlayerViewModel model, [FromQuery(Name = "next")] string next)
        {
            var dto       = new DrawTableRepositoryDto(int.Parse(model.TournamentId), model.TennisEventId);
            var drawTable = await this.drawTableUseCase.GetDrawTable(dto);

            var eligiblePlayersType = Enumeration.FromValue <EligiblePlayersType>(model.EligiblePlayersTypeId);

            await this.drawTableUseCase.UpdateEligiblePlayersType(drawTable, eligiblePlayersType);

            return(this.RedirectToAction(next, new
            {
                tournamentId = model.TournamentId,
                tennisEventId = model.TennisEventId,
            }));
        }
Esempio n. 4
0
        public async Task <string> GetEntryDetails(
            int tournamentId,
            string tennisEventId,
            [FromQuery(Name = "reacquisition")] bool?reacquisition,
            [FromQuery(Name = "eligiblePlayersTypeId")] int?eligiblePlayersTypeId,
            [FromQuery(Name = "participationClassification")] int?participationClassificationId)
        {
            if (tournamentId == 0)
            {
                return("[]");
            }

            var dto = new DrawTableRepositoryDto(tournamentId, tennisEventId)
            {
                IncludeEntryDetails           = true,
                IncludeEntryPlayers           = true,
                IncludeQualifyingDrawSettings = true,
                IncludeMainDrawSettings       = true,
            };
            var drawTable = await this.drawTableUseCase.GetDrawTable(dto);

            var tournament = await this.tournamentUseCase.GetTournament(drawTable.TournamentId);

            if (reacquisition ?? false)
            {
                var entryDetails
                    = await this.drawTableUseCase.RetrievePlayers(drawTable.TournamentId, drawTable.TennisEventId);

                drawTable.UpdateEntryDetails(entryDetails);
            }

            var eligiblePlayersType =
                eligiblePlayersTypeId.HasValue
                ? Enumeration.FromValue <EligiblePlayersType>(eligiblePlayersTypeId.Value)
                : null;

            var participationClassification =
                participationClassificationId.HasValue
                ? Enumeration.FromValue <ParticipationClassification>(participationClassificationId.Value)
                : null;

            return(this.drawTableUseCase.GetEntryDetailsJson(tournament, drawTable, eligiblePlayersType, participationClassification));
        }
Esempio n. 5
0
        public async Task <ActionResult> Create(int tournamentId, string tennisEventId)
        {
            this.ViewData["Action"] = "Create";
            var tournament = await this.tournamentUseCase.GetTournament(tournamentId);

            var tennisEvent = TennisEvent.FromId(tennisEventId);
            var dto         = new DrawTableRepositoryDto(tournamentId, tennisEventId);
            var drawTable   = await this.drawTableUseCase.GetDrawTable(dto);

            var useQualifyingMenu = drawTable.TournamentFormat == TournamentFormat.WithQualifying;

            return(this.View(new CreateViewModel(
                                 $"{tournament.Id}",
                                 tournament.TournamentName.Value,
                                 tennisEvent.TennisEventId,
                                 tennisEvent.DisplayTournamentEvent,
                                 tournament.HoldingDates.Select(o => o.DisplayValue),
                                 useQualifyingMenu,
                                 tennisEvent.IsSingles
                                 )));
        }
Esempio n. 6
0
        public async Task <ActionResult> Settings(int tournamentId, string tennisEventId)
        {
            this.ViewData["Action"] = "Settings";
            var tournament = await this.tournamentUseCase.GetTournament(tournamentId);

            var tennisEvent = TennisEvent.FromId(tennisEventId);
            var dto         = new DrawTableRepositoryDto(tournamentId, tennisEventId)
            {
                IncludeEntryDetails           = true,
                IncludeQualifyingDrawSettings = true,
                IncludeMainDrawSettings       = true,
            };
            var drawTable = await this.drawTableUseCase.GetDrawTable(dto);

            return(this.View(new SettingsViewModel(
                                 $"{tournament.Id}",
                                 tournament.TournamentName.Value,
                                 tennisEvent.TennisEventId,
                                 tennisEvent.DisplayTournamentEvent,
                                 drawTable
                                 )));
        }
Esempio n. 7
0
        public async Task <ActionResult> Players(int tournamentId, string tennisEventId)
        {
            this.ViewData["Action"] = "Players";
            var tournament = await this.tournamentUseCase.GetTournament(tournamentId);

            var tennisEvent = TennisEvent.FromId(tennisEventId);
            var dto         = new DrawTableRepositoryDto(tournamentId, tennisEventId)
            {
                IncludeEntryDetails = true,
            };
            var drawTable = await this.drawTableUseCase.GetDrawTable(dto);

            var useQualifyingMenu = drawTable.TournamentFormat == TournamentFormat.WithQualifying;

            return(this.View(new PlayerViewModel(
                                 $"{tournament.Id}",
                                 tournament.TournamentName.Value,
                                 tennisEvent.TennisEventId,
                                 tennisEvent.DisplayTournamentEvent,
                                 drawTable.EligiblePlayersType.Id,
                                 tournament.HoldingDates.Select(o => o.DisplayValue),
                                 useQualifyingMenu
                                 )));
        }
Esempio n. 8
0
        public async Task <HttpResponseMessage> RegisterDrawSettings(int tournamentId, string tennisEventId, [FromBody] JsonElement json)
        {
            var participationClassification = JsonConverter.ToEnumeration <ParticipationClassification>(json.GetProperty("participationClassification"));
            var dto = new DrawTableRepositoryDto(tournamentId, tennisEventId)
            {
                IncludeQualifyingDrawSettings = true,
                IncludeMainDrawSettings       = true,
                IncludeGames = true,
            };
            var drawTable = await this.drawTableUseCase.GetDrawTable(dto);

            var drawSettings = drawTable.GetDrawSettings(participationClassification);

            drawSettings.UpdateNumberOfBlocks(JsonConverter.ToInt32(json.GetProperty("numberOfBlocks")));
            drawSettings.UpdateNumberOfDraws(JsonConverter.ToInt32(json.GetProperty("numberOfDraws")));
            drawSettings.UpdateNumberOfEntries(JsonConverter.ToInt32(json.GetProperty("numberOfEntries")));
            drawSettings.UpdateNumberOfWinners(JsonConverter.ToInt32(json.GetProperty("numberOfWinners")));
            drawSettings.UpdateTournamentGrade(JsonConverter.ToInt32(json.GetProperty("tournamentGrade")));
            drawTable.UpdateDrawSettings(participationClassification, drawSettings);
            drawTable.Blocks.ChangeNumberOfBlocks(participationClassification, drawTable.QualifyingDrawSettings);
            await this.drawTableUseCase.UpdateDrawTable(drawTable);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }