public async Task <Result <Guid> > Handle(CreateGroupNotificationCommand request, CancellationToken token)
        {
            var user = await _context.Users.SingleAsync(e => e.Id == request.GroupId, token);

            var entity = new Domain.Notification(Guid.NewGuid(), NotificationKind.Business, request.Method,
                                                 request.Content,
                                                 user);

            await _context.AddAsync(entity, token);

            await _context.SaveChangesAsync(token);

            return(Success(entity.Id));
        }
        public static DTO.Notification Map(Domain.Notification notification)
        {
            Notification dto = new DTO.Notification
            {
                Id               = notification.Id,
                Title            = notification.Title,
                Content          = notification.Content,
                AppUserId        = notification.AppUserId,
                NotificationType = notification.NotificationType,
                TrainingId       = notification.TrainingId,
                Recived          = notification.Recived
            };

            return(dto);
        }
        public static Domain.Notification MapToDomain(DTO.Notification notification)
        {
            Domain.Notification domain = new Domain.Notification
            {
                Id               = notification.Id,
                Title            = notification.Title,
                Content          = notification.Content,
                AppUserId        = notification.AppUserId,
                NotificationType = notification.NotificationType,
                TrainingId       = notification.TrainingId,
                Recived          = notification.Recived
            };

            return(domain);
        }
        public async Task <bool> Handle(BalanceIncreasedIntegrationEvent @event)
        {
            var notification = new Domain.Notification(
                "Depósito efetuado com sucesso!",
                $"Um depósito de R$ {@event.Value} foi efetuado em sua conta!");

            var notificationUser = new NotificationUser(@event.UserId, notification);

            notificationUser.Send();

            await _notificationRepository.CreateNotificationUserAsync(notificationUser);

            await _notificationRepository.Commit();

            await _hubContext.Clients.All.Notify($"Depósito no valor de R$ {@event.Value} efetuado com sucesso!");

            return(true);
        }