public Output Process(IMessage input, IMessageContext model) { Console.WriteLine("start create tournament process"); var cmd = input as CreateTournamentCommand; var ctx_model = model as CreateTournamentCommandContextModel; var tournament_id = _id_provider.Get_new_id().ToString(); var created = _date_provider.Get_current_date().ToString(); Console.WriteLine($"id: { tournament_id }, created {created}"); var tournament_events = Map_tournament(tournament_id, created, cmd); var optins_events = Map_options(tournament_id, cmd); var player_events = ctx_model.Persons.Where(p => cmd.CompetitorsIds.Contains(p.Id)) .Select(p => Map_players(tournament_id, p)); var events = tournament_events.Concat(optins_events).Concat(player_events).ToArray(); Console.WriteLine($"events count: { events.Count() }"); return(new CommandOutput(new Success(), events)); }
private Tournament Initialize_tournament_datas(CreateTournamentCommand command) { var tournament = new Tournament(); tournament.Id = _id_provider.Get_new_id(); tournament.Name = command.Name; tournament.Date = _date_Provider.Get_current_date(); var options = new Options(); options.Tables = command.Tables; options.Points = command.Points; options.Sets = command.Sets; options.Points_on_tied = command.PointsTied; options.Tied = command.Tied; options.Walkover = command.Walkover; options.Fair_lots = command.FairLots; tournament.Options = options; tournament.Rounds = new List <Round>(); return(tournament); }