public bool SendAppNotification(NotificationProjection viewModel, List <string> listOfPlayerId, List <ListOfPlayerId> finalPlayerId, int savedNotificationId)
        {
            var sendNotificationService = DependencyResolver.Current.GetService <ISendNotificationService>();
            var getfinalPlayerId        = (from list in finalPlayerId
                                           group finalPlayerId by new
            {
                list.SId,
                list.ParentPlayerId
            } into grouping
                                           select new ListOfPlayerId
            {
                SId = grouping.Key.SId,
                ParentPlayerId = grouping.Key.ParentPlayerId
            }).ToList();

            listOfPlayerId = listOfPlayerId.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();
            if (listOfPlayerId.Count > 0)
            {
                var i = 0;
                SendNotificationByPlayerId[] notification = new SendNotificationByPlayerId[getfinalPlayerId.Count()];
                foreach (var playerId in getfinalPlayerId)
                {
                    var studentSId          = playerId.SId;
                    var sendAppNotification = new SendNotificationByPlayerId
                    {
                        Message    = "Notice-" + viewModel.NotificationMessage + "$^$" + playerId.SId + "@" + savedNotificationId,
                        PlayerIds  = playerId.ParentPlayerId,
                        AppIds     = ConfigurationManager.AppSettings[Common.Constants.ParentAppId],
                        RestApiKey = ConfigurationManager.AppSettings[Common.Constants.ParentRestAppId]
                    };
                    notification[i] = sendAppNotification;
                    i++;
                }

                if (viewModel.AllUser)
                {
                    HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => sendNotificationService.StartProcessingByPlayerId(notification, cancellationToken));
                }
                else
                {
                    HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => sendNotificationService.StartProcessingByPlayerId(notification, cancellationToken));
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        private Configuration()
        {
            _bus = new MessageBus();
            var eventStore = new SqlEventStore(_bus);
            var repository = new DomainRepository(eventStore);

            var commandService = new AccountApplicationService(repository);

            _bus.RegisterHandler <RegisterAccountCommand>(commandService.Handle);
            _bus.RegisterHandler <DebitAccountCommand>(commandService.Handle);
            _bus.RegisterHandler <UnlockAccountCommand>(commandService.Handle);

            var infoProjection = new AccountInfoProjection();

            _bus.RegisterHandler <AccountRegisteredEvent>(infoProjection.Handle);
            _bus.RegisterHandler <AccountLockedEvent>(infoProjection.Handle);
            _bus.RegisterHandler <AccountUnlockedEvent>(infoProjection.Handle);

            var balanceProjection = new AccountBalanceProjection();

            _bus.RegisterHandler <AccountRegisteredEvent>(balanceProjection.Handle);
            _bus.RegisterHandler <AccountDebitedEvent>(balanceProjection.Handle);

            var notification = new NotificationProjection();

            _bus.RegisterHandler <AccountRegisteredEvent>(notification.Handle);
            _bus.RegisterHandler <AccountDebitedEvent>(notification.Handle);
            _bus.RegisterHandler <AccountLockedEvent>(notification.Handle);
            _bus.RegisterHandler <AccountUnlockedEvent>(notification.Handle);
            _bus.RegisterHandler <OverdrawAttemptedEvent>(notification.Handle);

            _readModel = new ReadModelFacade(balanceProjection, infoProjection, notification);

            var events = eventStore.GetAllEventsEver();

            _bus.Publish(events);
        }
Ejemplo n.º 3
0
 public ReadModelFacade(AccountBalanceProjection balance, AccountInfoProjection info, NotificationProjection notification)
 {
     AccountBalances = balance.AccountBalances;
     AccountInfos    = info.AccountInfos;
     Notifications   = notification.Notifications;
 }