コード例 #1
0
        public async Task <IApplicationResult> ConfirmEmailAsync(Guid id)
        {
            return(await ExecuteAsync(async() =>
            {
                var user = await _unitOfWork.Users.GetByIdAsync(id);

                if (user == null)
                {
                    throw new ObjectNotFoundException($"User with Id={id} not found");
                }

                user.EmailConfirmed = true;

                await _unitOfWork.Users.UpdateAsync(user);

                var template = await _templateFactory.CreateForUserEmailConfirmedAsync(user);
                var templateRendered = await _templateService.RenderAsync <string>(template);

                return new OkApplicationResult <string>
                {
                    Data = templateRendered
                };
            }, false));
        }