Ejemplo n.º 1
0
        public async Task <Result> SendEmilVerificationMail(SendEmailVerificationMailRequest request, string adminId)
        {
            ValidationResult validationResult = _sendEmailVerificationMailValidator.Validate(request);

            if (!validationResult.IsValid)
            {
                _logger.LogWarning($"Invlid SendEmailVerificationMailRequest. AdminId {adminId}");
                return(Result.Fail(validationResult.Errors));
            }

            BaseSpecification <AppUserEntity> userSpecification = new BaseSpecification <AppUserEntity>();

            userSpecification.AddFilter(x => x.Id == request.UserId);

            AppUserEntity appUser = _userRepository.SingleOrDefault(userSpecification);

            if (appUser == null)
            {
                _logger.LogWarning($"No User. UserId {request.UserId}, AdminId {adminId}");
                return(Result.Fail("no_user", "No user"));
            }

            string code = await _userManager.GenerateEmailConfirmationTokenAsync(appUser);

            await _emailConfirmationService.SendVerificationMail(appUser, code);

            return(Result.Ok());
        }
Ejemplo n.º 2
0
        public async Task <CommonUtils.Result.Result> SendEmilVerificationMail(long groupUserId)
        {
            IBaseSpecification <GroupUserEntity, GroupUserEntity> specification = SpecificationBuilder
                                                                                  .Create <GroupUserEntity>()
                                                                                  .Where(x => x.Id == groupUserId)
                                                                                  .Include(x => x.User)
                                                                                  .Build();

            CommonUtils.Result.Result <GroupUserEntity> getGroupUserResult = await _groupUserStore.SingleOrDefault(specification);

            if (getGroupUserResult.Failure)
            {
                return(CommonUtils.Result.Result.Fail(getGroupUserResult));
            }

            SendEmailVerificationMailRequest sendEmailVerificationMailRequest = new SendEmailVerificationMailRequest(
                userId: getGroupUserResult.Value.UserId);

            Core.Models.Result.Result result = await SendEmilVerificationMail(sendEmailVerificationMailRequest, "");

            return(result.ToNewResult());
        }