/// <summary> /// エントリー詳細の新しいインスタンスを生成します。 /// </summary> /// <param name="entryNumber">エントリー番号。</param> /// <param name="participationClassification">出場区分。</param> /// <param name="seedNumber">シード番号。</param> /// <param name="entryPlayers">選手情報一覧。</param> /// <param name="canParticipationDates">出場可能日一覧。</param> /// <param name="receiptStatus">受領状況。</param> /// <param name="usageFeatures">利用機能。</param> /// <param name="fromQualifying">予選からの進出者かどうか示す値。</param> /// <param name="blockNumber">ブロック番号。</param> public EntryDetail( EntryNumber entryNumber, ParticipationClassification participationClassification, SeedNumber seedNumber, IEnumerable <EntryPlayer> entryPlayers, IEnumerable <CanParticipationDate> canParticipationDates, ReceiptStatus receiptStatus, UsageFeatures usageFeatures, bool fromQualifying = false, BlockNumber blockNumber = null) { this.EntryNumber = entryNumber; this.ParticipationClassification = participationClassification; this.SeedNumber = seedNumber; this.EntryPlayers = new EntryPlayers(entryPlayers); this.CanParticipationDates = new CanParticipationDates(canParticipationDates); this.ReceiptStatus = receiptStatus; this.UsageFeatures = usageFeatures; this.FromQualifying = fromQualifying; if (!this.FromQualifying) { return; } this.BlockNumber = blockNumber ?? throw new ArgumentNullException("ブロック番号"); }
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)); }