Beispiel #1
0
        public AddPersonActor(DockkaContext context)
        {
            // Due to distributed systems, we have to subscribe to 'queryPerson'
            var mediator = DistributedPubSub.Get(Context.System).Mediator;

            mediator.Tell(new Subscribe("addPerson", Self));

            ReceiveAsync <IAddPersonMessage>(async personEvent =>
            {
                Log.Information($"addPerson received person: (FirstName {personEvent.Person.FirstName}, LastName {personEvent.Person.LastName}).");
                // Add the person to the DB
                var entry = await context.AddAsync(personEvent.Person);
                await context.SaveChangesAsync();

                // And request the query actor to get that person
                mediator.Tell(new Publish("queryPerson", new QueryPersonMessage {
                    Id = entry.Entity.Id
                }));
            });
        }
Beispiel #2
0
        public QueryPersonActor(DockkaContext context)
        {
            // Due to distributed systems, we have to subscribe to 'queryPerson'
            var mediator = DistributedPubSub.Get(Context.System).Mediator;

            mediator.Tell(new Subscribe("queryPerson", Self));

            ReceiveAsync <IQueryPersonMessage>(async queryMessage =>
            {
                Log.Information("queryPerson received person");

                // Get the person from the database
                var person = await context.FindAsync <Person>(queryMessage.Id);

                // Request the UI actor to update the UI
                mediator.Tell(new Publish("updateUi", new UpdateUiMessage {
                    Person = person
                }));
            });
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DockkaContext context)
        {
            // Auto-migrate (for docker especially)
            context.Database.Migrate();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Map Swagger
            app.UseSwagger();
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "V1 Docs");
            });
            app.UseMvc();

            app.UseCors("Everything");

            app.UseSignalR(routes => routes.MapHub <PersonsHub>("persons"));
        }
Beispiel #4
0
 public PersonsController(DockkaContext context) : base(context)
 {
 }
Beispiel #5
0
 public BaseEntityController(DockkaContext context)
 {
     Context = context;
     Set     = context.Set <T>();
 }