Exemplo n.º 1
0
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                var user = _context.Set <User>().Where(x => x.Username == request.Email).SingleOrDefault();

                if (user != null)
                {
                    return(null);
                }

                var quote = await _context.FindAsync <Quote>(request.QuoteId);

                if (quote == null || quote.Declined.HasValue || quote.Accepted.HasValue)
                {
                    return(null);
                }

                return(new Response(_tokenProvider.Get(request.Email,
                                                       new List <Claim> {
                    new Claim(Core.Constants.ClaimTypes.Role, nameof(Core.Constants.Roles.Lead))
                })));
            }
Exemplo n.º 2
0
        public async System.Threading.Tasks.Task Handle(QuoteCreated notification, CancellationToken cancellationToken)
        {
            var primaryParticpantEmail = notification.Quote.BillToEmail;

            var user = _context.Set <User>().SingleOrDefault(x => x.Username == primaryParticpantEmail);

            user ??= new User(primaryParticpantEmail);

            if (user.DomainEvents.Any())
            {
                var profile = new Lead(primaryParticpantEmail);

                var account = new Account(profile.ProfileId, "", user.UserId);

                _store.Add(profile);

                _store.Add(account);

                _store.Add(user);

                await _store.SaveChangesAsync(cancellationToken);
            }
        }