Example #1
0
        public Task Handle(DomainEventNotification <ContactCreatedEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            _logger.LogInformation("jCoreDemoApp Domain Event: {DomainEvent}", domainEvent.GetType().Name);

            return(Task.CompletedTask);
        }
Example #2
0
 public async Task Handle(DomainEventNotification <DiscordGuildDownloadCompleteEvent> notification, CancellationToken cancellationToken)
 {
     _scheduler.ConfigureJobWithCronSchedule <ApplyConditionalRolesJob>(_logger, _configuration, "BackgroundTasks:ApplyConditionalRolesCronExpression");
     _scheduler.ConfigureJobWithCronSchedule <ApplyJoinRolesJob>(_logger, _configuration,
                                                                 "BackgroundTasks:ApplyJoinRolesCronExpression");
     _scheduler.ConfigureJobWithCronSchedule <BoosterCycleJob>(_logger, _configuration,
                                                               "BackgroundTasks:BoosterCycleCronExpression");
 }
Example #3
0
        public Task Handle(DomainEventNotification <TodoItemCreatedEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            _logger.LogInformation("Domain event - {domainEvent} handled", domainEvent.GetType().Name);

            return(Task.CompletedTask);
        }
        public Task Handle(DomainEventNotification <ProductCreatedEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            _logger.LogInformation("CleanArchitecture Domain Event: {DomainEvent}", domainEvent.GetType().Name);

            return(Task.CompletedTask);
        }
        public async Task Handle(DomainEventNotification <SavedActivity> notification,
                                 CancellationToken cancellationToken)
        {
            Activity          activity      = notification.DomainEvent.Activity;
            ActivityViewModel activityModel = _mapper.Map <ActivityViewModel>(activity);

            await _hubContext.Clients.Groups("Clients").SendAsync("NewActivity", activityModel, cancellationToken);
        }
 public async Task Handle(DomainEventNotification <DiscordConnectionChangeEvent> notification,
                          CancellationToken cancellationToken)
 {
     if (notification.DomainEvent.Status == DiscordConnectionStatus.Ready)
     {
         await _mediator.Send(new PopulateBoosterServiceCommand(), cancellationToken);
     }
 }
        public Task Handle(DomainEventNotification <TodoItemCompletedEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            _logger.LogInformation("LowCostFligtsBrowser Domain Event: {DomainEvent}", domainEvent.GetType().Name);

            return(Task.CompletedTask);
        }
Example #8
0
 public async Task Handle(DomainEventNotification <SavedServiceRequest> notification,
                          CancellationToken cancellationToken)
 {
     ServiceRequestViewModel serviceRequestModel =
         _mapper.Map <ServiceRequestViewModel>(notification.DomainEvent.ServiceRequest);
     await _hubContext.Clients.Groups("Administrator", "OfficeEmployee")
     .SendAsync("NewServiceRequest", serviceRequestModel, cancellationToken);
 }
Example #9
0
        public Task Handle(DomainEventNotification <DeliveryCreatedEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            _logger.LogInformation("Post Domain Event: {DomainEvent}", domainEvent.GetType().Name);

            return(Task.CompletedTask);
        }
Example #10
0
        public Task Handle(DomainEventNotification <HoldingPurchasedEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            _logger.LogInformation("NetworthApplication Domain Event: {DomainEvent} with ticker {Ticker}", domainEvent.GetType().Name, domainEvent.Holding.Ticker);

            return(Task.CompletedTask);
        }
Example #11
0
        public Task Handle(DomainEventNotification <TodoItemCompletedEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            _logger.LogInformation("clean_architecture_grpc Domain Event: {DomainEvent}", domainEvent.GetType().Name);

            return(Task.CompletedTask);
        }
        public Task Handle(DomainEventNotification <CaseCreatedEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            logger.LogInformation("DrWhistle Domain Event: {DomainEvent}", domainEvent.GetType().Name);

            return(Task.CompletedTask);
        }
Example #13
0
        public Task Handle(DomainEventNotification <RatingCompletedEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            _logger.LogInformation("demo_ca_app Domain Event: {DomainEvent}", domainEvent.GetType().Name);

            return(Task.CompletedTask);
        }
Example #14
0
        public Task Handle(DomainEventNotification <TodoItemCompletedEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            _logger.LogInformation("CustomerRelationship Domain Event: {DomainEvent}", domainEvent.GetType().Name);

            return(Task.CompletedTask);
        }
        public async Task Handle(DomainEventNotification <BillingExportProcessingEvent> notification,
                                 CancellationToken token)
        {
            var pickingOrderEvent = notification.DomainEvent;
            var job = await _context.Jobs.SingleAsync(e => e.Id == pickingOrderEvent.JobId, token);

            await _signalrService.SendNotificationToUserAsync(job.UserId, nameof(BillingExportProcessingEvent),
                                                              new { JobId = job.Id, Name = job.Name, UserId = job.UserId });
        }
 public async Task Handle(DomainEventNotification <ParticipationSessionReady> notification,
                          CancellationToken cancellationToken)
 {
     await _hub.Clients
     .Group(notification.DomainEvent.ParticipationId.ToString())
     .OnReady(new ParticipationReadyEvent(
                  notification.DomainEvent.ParticipationId.Value
                  ));
 }
 public async Task Handle(DomainEventNotification <ProcessStarted> notification,
                          CancellationToken cancellationToken)
 {
     await _hub.Clients
     .Group(notification.DomainEvent.ParticipationId.ToString())
     .OnProcessStart(new ParticipationProcessStartEvent(
                         notification.DomainEvent.ParticipationId.Value
                         ));
 }
 public async Task Handle(DomainEventNotification <ParticipationUserRemoved> notification,
                          CancellationToken cancellationToken)
 {
     await _hub.Clients
     .Group(notification.DomainEvent.ParticipationId.ToString())
     .OnDisconnectedUser(new (
                             notification.DomainEvent.UserId.Value
                             ));
 }
        public async Task Handle(DomainEventNotification <UpdatedServiceRequest> notification,
                                 CancellationToken cancellationToken)
        {
            var serviceRequest = notification.DomainEvent.ServiceRequest;

            if (serviceRequest.State == ServiceRequestState.Pending)
            {
                return;
            }

            var client =
                await _clientsRepository.GetClientWithUser(serviceRequest.ClientId);

            string responseMessage = serviceRequest.State switch
            {
                ServiceRequestState.Accepted =>
                "Hemos aceptado tu solicitud de servicio y agendamos las actividades a aplicar.",
                ServiceRequestState.Rejected => "Desafortunadamente hemos rechazado tu solicitud de servicio.",
                ServiceRequestState.PendingSuggestedDate =>
                "Te hemos sugerido una nueva fecha de aplicación de nuestros servicios.",
                _ => "Tu solicitud aún está pendiente"
            };

            var responseUrl = new UriBuilder(KaizenHttpContext.BaseUrl)
            {
                Path = serviceRequest.State switch
                {
                    ServiceRequestState.Accepted => "/activity_schedule/client_schedule",
                    ServiceRequestState.Rejected => "/service_requests/register",
                    ServiceRequestState.PendingSuggestedDate => "/service_requests/new_date",
                    _ => $"/service_requests/{serviceRequest.Code}"
                }
            };

            var responseButtonMessage = serviceRequest.State switch
            {
                ServiceRequestState.Accepted => "Ver mi calendario de actividades",
                ServiceRequestState.Rejected => "Intentar hacer otra solicitud",
                ServiceRequestState.PendingSuggestedDate => "Ver fecha sugerida",
                _ => "Ver solicitud"
            };

            string emailMessage = _mailTemplate.LoadTemplate("ServiceRequestResponse.html",
                                                             $"{client.FirstName} {client.LastName}",
                                                             responseMessage,
                                                             responseUrl.ToString(),
                                                             responseButtonMessage);

            await _mailService.SendEmailAsync(
                client.User.Email,
                "Respuesta de solicitud de servicio",
                emailMessage,
                true);
        }
    }
}
Example #20
0
        public async Task Handle(DomainEventNotification <PickingOrderExportProcessingEvent> notification,
                                 CancellationToken token)
        {
            var pickingOrderEvent = notification.DomainEvent;
            var job = await _context.Jobs.SingleAsync(e => e.Id == pickingOrderEvent.JobId, token);

            var jobIdentifier = _idSerializer.Serialize("Query", nameof(Job), job.Id);
            await _signalrService.SendNotificationToUserAsync(job.UserId, nameof(PickingOrderExportProcessingEvent),
                                                              new { JobId = jobIdentifier, Name = job.Name, UserId = job.UserId });
        }
Example #21
0
        public async Task Handle(DomainEventNotification <ProjectAssignmentDeletedEvent> notification, CancellationToken cancellationToken)
        {
            var deleteUserAssignmentsCommand = new DeleteUsersAssignmentsCommand()
            {
                ProjectId = notification.DomainEvent.ProjectId,
                UserId    = notification.DomainEvent.UserId
            };

            await _mediator.Send(deleteUserAssignmentsCommand, cancellationToken);
        }
 public async Task Handle(DomainEventNotification <SurveyCreatedDomainEvent> notification, CancellationToken cancellationToken)
 {
     await _notificationService.SendMessage(new MessageDto
     {
         Body    = $"Survey with ID: {notification.DomainEvent.Survey.Id} created",
         From    = "System",
         Subject = "New Survey Created",
         To      = "Whom It May Concern"
     }, cancellationToken);
 }
        public async Task Handle(DomainEventNotification <PurchaseOrderExpiredEvent> notification,
                                 CancellationToken token)
        {
            var orderEvent    = notification.DomainEvent;
            var purchaseOrder =
                await _context.PurchaseOrders.SingleAsync(e => e.Id == orderEvent.PurchaseOrderId, token);

            await NotifyProducerAsync(purchaseOrder, token);
            await NotifyConsumerAsync(purchaseOrder, token);
        }
        public Task Handle(DomainEventNotification <OcorrenciaCriadaEvent> notification, CancellationToken cancellationToken)
        {
            var domainEvent = notification.DomainEvent;

            // Oficiar ocorrência

            _logger.LogInformation($"CleanArchitecture Domain Event: {domainEvent.GetType().Name}");

            return(Task.CompletedTask);
        }
Example #25
0
        public async Task Handle(DomainEventNotification <UpdatedWorkOrder> notification,
                                 CancellationToken cancellationToken)
        {
            WorkOrder workOrder = notification.DomainEvent.WorkOrder;

            if (workOrder.WorkOrderState == WorkOrderState.Valid)
            {
                await _statisticsRepository.RegisterNewAppliedActivity();
            }
        }
 private async Task PublishEvents(Client client)
 {
     foreach (var ev in client.DomainEvents)
     {
         var   dev    = DomainEventNotification.Create(ev);
         var   method = sut.GetType().GetMethod("Handle", new[] { dev.GetType(), typeof(CancellationToken) });
         var   task   = method?.Invoke(sut, new object[] { dev, default(CancellationToken) }) as Task;
         await task;
     }
     client.ClearDomainEvents();
 }
        public async Task Handle(DomainEventNotification <ItemPurchasedEvent> notification, CancellationToken cancellationToken)
        {
            var purchaseItem = notification.DomainEvent.Item;
            var product      = await _context.Products.FirstOrDefaultAsync(p => p.Id == purchaseItem.ProductId, cancellationToken);

            if (product != null)
            {
                product.RemainingStock += purchaseItem.Quantity;
            }
            await _context.SaveChangesAsync(cancellationToken);
        }
        public async Task Handle(DomainEventNotification <SavedActivity> notification,
                                 CancellationToken cancellationToken)
        {
            Activity activity = notification.DomainEvent.Activity;
            Client   client   = activity.Client;

            string emailMessage = _mailTemplate.LoadTemplate("NewActivity.html",
                                                             $"{client.LastName} {client.FirstName}", activity.Date.ToString("yyyy/MM/dd hh:mm tt"));

            await _mailService.SendEmailAsync(client.User.Email, "Solicitud de servicios", emailMessage, true);
        }
Example #29
0
        public async Task Handle(DomainEventNotification <DocumentDeletedEvent> notification, CancellationToken cancellationToken = default)
        {
            var ev = notification.Event;

            _db.DocumentHistories
            .Add(DocumentHistory.DocumentDeleted(
                     ev.Timestamp,
                     ev.Entity.Id,
                     ev.Path.ToString()));
            await _db.SaveChangesAsync();
        }
        public async Task Handle(DomainEventNotification <UserEmailChangedEvent> notification,
                                 CancellationToken cancellationToken)
        {
            var changeUserEmailCommand = new ChangeUserEmailCommand()
            {
                ApplicationUserEmail    = notification.DomainEvent.ApplicationUserEmail,
                ApplicationUserNewEmail = notification.DomainEvent.ApplicationUserNewEmail,
            };

            await _mediator.Send(changeUserEmailCommand, cancellationToken);
        }