Beispiel #1
0
 public AddRecipientsSelectionsHandler(IUnitOfWork unitOfWork, ISelectionFactory selectionFactory, IRecipientFactory recipientFactory, IRecipientRepository recipientRepository, ISelectionRepository selectionRepository, ISharingRepository sharingRepository, ISharingFactory sharingFactory, IValidator[] validator, ICommandHandlerDispatcher commandHandlerDispatcher)
 {
     _unitOfWork               = unitOfWork;
     _selectionFactory         = selectionFactory;
     _recipientFactory         = recipientFactory;
     _recipientRepository      = recipientRepository;
     _selectionRepository      = selectionRepository;
     _sharingFactory           = sharingFactory;
     _sharingRepository        = sharingRepository;
     _validator                = validator;
     _commandHandlerDispatcher = commandHandlerDispatcher;
 }
Beispiel #2
0
        public async Task <IActionResult> GetNavbarAsync([FromServices] IUnitOfWorkFactory unitOfWorkFactory,
                                                         [FromServices] ICommandHandlerDispatcher commandHandlerDispatcher,
                                                         [FromServices] IQueryHandlerDispatcher queryHandlerDispatcher)
        {
            var unitOfWork = unitOfWorkFactory.Create();

            var cmd = new CreateNotificationCommand("xact", "notif-" + Guid.NewGuid().ToString(), 1, "subject1", "content1", "reference1", DateTime.UtcNow);

            commandHandlerDispatcher.Handle(cmd);

            var query = new GetUnreadNotificationReceiversByUserIdQuery("xact", "system-administrator", "", 1, 10, "", true);
            var dto   = queryHandlerDispatcher.Handle <GetUnreadNotificationReceiversByUserIdQuery, PaginatedNotificationReceiverDto>(query);


            //var items = await notificationService.GetUnreadNotificationsAsync(UserId);
            //var notifications = items.OrderByDescending(p => p.Notification.DateSent).Take(15).ToList();

            ////var items2 = await messageService.GetUnreadMessagesAsync(UserId);
            ////var msgHeaders = items2.Take(15).ToList();

            //var chats = await appDbContext
            //    .ChatReceiverMessages
            //    .Include(p => p.ChatMessage)
            //        .ThenInclude(p => p.Sender)
            //            .ThenInclude(p => p.User)
            //    //.Include(p => p.ChatReceiver)
            //    .Where(p => p.ChatReceiver.ReceiverId == UserId && p.IsRead == false)
            //    .Take(15)
            //    .ToListAsync();

            ////  trigger populate
            ////var chatReceivers = await appDbContext
            ////    .ChatReceivers
            ////    .Where(p => p.ReceiverId == UserId)
            ////    .ToListAsync();


            //var model = new NavbarInfo
            //{
            //    Username = User.Identity.Name,
            //    NotificationReceivers = notifications,
            //    MessageReceiverMessages = chats
            //};


            //return Ok(model);
            unitOfWork.Commit();

            return(Ok(dto));
        }
Beispiel #3
0
        public void OnGet([FromServices] ICommandHandlerDispatcher commandHandlerDispatcher)
        {
            //var cmd1 = new CreateAppCommand(string.Empty, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), string.Empty, 1);

            ////var cmd2 = new CreateAppCommand(string.Empty, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), string.Empty, 1);
            ////commandHandlerDispatcher.Handle(cmd2);

            ////var cmd2 = new CreateModuleCommand(string.Empty, cmd1.AppId, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "1x", "x", "x", 1);
            ////var cmd3 = new CreateModuleCommand(string.Empty, cmd1.AppId, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "2x", "x", "x", 1);


            //commandHandlerDispatcher.Handle(cmd1);
            ////commandHandlerDispatcher.Handle(cmd2);
            ////commandHandlerDispatcher.Handle(cmd3);



            //unitOfWork.Commit();
            //unitOfWork.Rollback();
        }