Example #1
0
 public Team(ILogger <Team> logger, ICommandSender bus, TeamRepository repository, TeamsView view)
 {
     _logger = logger;
     _bus    = bus;
     _writeModelRepository = repository;
     _readModelView        = view;
 }
Example #2
0
 public MainViewModel()
 {
     TeamViewModel       = new TeamViewModel();
     PlayersViewModel    = new PlayersViewModel();
     RefereesViewModel   = new RefereesViewModel();
     TournamentViewModel = new TournamentViewModel();
     TournamentView      = new TournamentView(TournamentViewModel, PlayersViewModel, TeamViewModel, RefereesViewModel);
     TeamsView           = new TeamsView(TeamViewModel, PlayersViewModel);
     PlayersView         = new PlayersView(PlayersViewModel);
     RefereeView         = new RefereeView(RefereesViewModel);
 }
Example #3
0
        /// <summary>
        /// Configure read and write models
        /// </summary>
        public static void ConfigureModels(this IApplicationBuilder app, TeamRepository repo, TeamsView teamsView, TeamCommandHandler commandHandler)
        {
            // Read models (Queries) setup

            var snapshot = // Current data snapshot: we retrieve all the aggregates from the repository
                           repo.GetIds(0, int.MaxValue).ToArray()
                           .Select(id => repo.Find(id))
                           .Select(x => new ReadModel.Teams.DTO.TeamDto(x));

            teamsView.LoadSnapshot(snapshot);


            // Write models (Commands) setup

            // Nothing to do (handler registration is done in the TeamCommandHandler constructor)
            // Note that although not used, the dependency on TeamCommandHandler as a parameters to this method forces its instantiation
            // (otherwise - unless used elsewhere - the DI system would never invoke the implementation factory delegate passed to AddSingleton)
        }