コード例 #1
0
        public Task <UserSummary> ExecuteAsync(GetCurrentUserSummaryQuery query, IExecutionContext executionContext)
        {
            if (!executionContext.UserContext.UserId.HasValue)
            {
                return(null);
            }

            var userQuery = new GetUserSummaryByIdQuery(executionContext.UserContext.UserId.Value);

            return(_queryExecutor.ExecuteAsync(userQuery, executionContext));
        }
コード例 #2
0
        private async Task <ICurrentUserViewHelperContext> GetHelperContextAsync(IUserContext userContext)
        {
            var context = new CurrentUserViewHelperContext();

            context.Role = await _queryExecutor.ExecuteAsync(new GetRoleDetailsByIdQuery(userContext.RoleId), userContext);

            if (userContext.UserId.HasValue)
            {
                var query = new GetUserSummaryByIdQuery(userContext.UserId.Value);
                context.Data = await _queryExecutor.ExecuteAsync(query, userContext);

                context.IsSignedIn = true;
            }

            return(context);
        }
        private async Task SendNotificationAsync(AddUserCommand newUserCommand, IExecutionContext executionContext)
        {
            var query = new GetUserSummaryByIdQuery(newUserCommand.OutputUserId);
            var user  = await _queryExecutor.ExecuteAsync(query, executionContext);

            EntityNotFoundException.ThrowIfNull(user, newUserCommand.OutputUserId);

            // Send mail notification
            var context             = _userMailTemplateBuilderContextFactory.CreateNewUserWithTemporaryPasswordContext(user, newUserCommand.Password);
            var mailTemplateBuilder = _userMailTemplateBuilderFactory.Create(newUserCommand.UserAreaCode);
            var mailTemplate        = await mailTemplateBuilder.BuildNewUserWithTemporaryPasswordTemplateAsync(context);

            // Null template means don't send a notification
            if (mailTemplate == null)
            {
                return;
            }

            await _mailService.SendAsync(newUserCommand.Email, mailTemplate);
        }