Exemplo n.º 1
0
        public async Task <Unit> Handle(ConfirmNationalCardCommand request, CancellationToken cancellationToken)
        {
            var username = await _identityService.GetUserNameAsync(request.UserId);

            if (username == null)
            {
                throw new NotFoundException();
            }

            var document =
                await _context.Documents.FirstOrDefaultAsync(f => f.CreatedBy == request.UserId, cancellationToken);

            if (document == null)
            {
                throw new NotFoundException(nameof(Document), request.UserId);
            }

            document.NationalCardImageStatus =
                request.IsConfirm ? DocumentImagesStatus.Confirmed : DocumentImagesStatus.Rejected;

            await _context.SaveChangesAsync(cancellationToken);

            if (request.IsConfirm)
            {
                await _identityService.AddConfirmsClaim(request.UserId, "NationalCard");
            }

            return(Unit.Value);
        }
Exemplo n.º 2
0
        public async Task <Unit> Handle(ConfirmBankCardCommand request, CancellationToken cancellationToken)
        {
            var username = await _identityService.GetUserNameAsync(request.UserId);

            if (username == null)
            {
                throw new NotFoundException();
            }

            var financial =
                await _context.FinancialInformation.FirstOrDefaultAsync(f => f.Id == request.FinancialId, cancellationToken);

            if (financial == null)
            {
                throw new NotFoundException(nameof(FinancialInfo), request.FinancialId);
            }

            financial.Status =
                request.IsConfirm ? Status.Confirmed : Status.Rejected;

            await _context.SaveChangesAsync(cancellationToken);

            if (request.IsConfirm)
            {
                await _identityService.AddConfirmsClaim(request.UserId, "BankCard");
            }

            return(Unit.Value);
        }
Exemplo n.º 3
0
        public async Task <Unit> Handle(ConfirmTellCommand request, CancellationToken cancellationToken)
        {
            var username = await _identityService.GetUserNameAsync(request.UserId);

            if (username == null)
            {
                throw new NotFoundException();
            }

            var profile =
                await _context.UsersProfiles.FirstOrDefaultAsync(f => f.UserId == request.UserId, cancellationToken);

            if (profile == null)
            {
                throw new NotFoundException(nameof(UserProfile), request.UserId);
            }

            profile.TellConfirmed = request.IsConfirm;

            await _context.SaveChangesAsync(cancellationToken);

            if (request.IsConfirm)
            {
                await _identityService.AddConfirmsClaim(request.UserId, "Tell");
            }

            return(Unit.Value);
        }