public async Task <PushNonce> Handle(GeneratePushNonceCommand request, CancellationToken cancellationToken)
        {
            var profile = await repository.GetProfileAsync(request.ProfileId, request.DeviceId, cancellationToken);

            if (profile == null)
            {
                throw new DomainException("Profile not found");
            }

            if (string.IsNullOrEmpty(profile.PushToken))
            {
                throw new DomainException("Push token is required please update profile");
            }

            var instanceInfo = await instanceIdService.GetInstanceInfoAsync(profile.PushToken, cancellationToken);

            if (instanceInfo == null)
            {
                throw new DomainException("Push token is invalid");
            }

            if (instanceInfo.Platform != profile.ClientInfo.OperationSystem || instanceInfo.Application != profile.ClientInfo.Integrator)
            {
                throw new DomainException("Push token is invalid or from wrong platform");
            }

            var pushNonce = await context.PushNonces.SingleOrDefaultAsync(x => x.Id == profile.PushToken, cancellationToken);

            if (pushNonce != null)
            {
                pushNonce.Update(nonceGenerator.Generate(), DateTime.UtcNow, DateTime.UtcNow.Add(request.TokenExpiration));
            }
            else
            {
                pushNonce = new PushNonce(profile.PushToken, nonceGenerator.Generate(), DateTime.UtcNow, DateTime.UtcNow.Add(request.TokenExpiration));
                await context.PushNonces.AddAsync(pushNonce, cancellationToken);
            }

            await context.SaveChangesAsync(cancellationToken);

            var message = new Notification
            {
                Data = new Dictionary <string, object>
                {
                    { "type", "PUSH_NONCE" },
                    { "Nonce", pushNonce.Body }
                },
                Priority         = "high",
                ContentAvailable = true
            };
            var sendNonceCommand = new SendPushNotificationCommand(profile.Id, message);
            await mediator.Send(sendNonceCommand, cancellationToken);

            return(pushNonce);
        }
        protected override void Handle(StoreNonceCommand request)
        {
            if (string.IsNullOrEmpty(request.CovidPass))
            {
                throw new DomainException($"{nameof(request.CovidPass)} cannot be null or empty");
            }

            var cacheEntry = new CovidPassNonceCacheEntry(request.CovidPass, nonceGenerator.Generate());

            memoryCache.Set(cacheEntry.Key, cacheEntry, TimeSpan.FromSeconds(15));
        }