コード例 #1
0
        public IActionResult Index(int code)
        {
            var metadata = new MedioClinic.Models.PageMetadata();

            if (code == 404)
            {
                _logger.LogError($"Not found: {ExceptionHandlerPathFeature?.Path}");

                var notFoundPage = _pageRepository.GetPagesInCurrentCulture(
                    filter => filter
                    .Path("/Reused-content/Error-pages/Not-found")
                    .CombineWithDefaultCulture(),
                    buildCacheAction: cache => cache
                    .Key($"{nameof(ErrorController)}|NotFoundPage")
                    .Dependencies((_, builder) => builder
                                  .PageType(CMS.DocumentEngine.Types.MedioClinic.NamePerexText.CLASS_NAME)),
                    includeAttachments: false)
                                   .FirstOrDefault();

                metadata.Title = notFoundPage.Name;
                var viewModel = GetPageViewModel(metadata, notFoundPage);

                return(View("NotFound", viewModel));
            }

            _logger.LogError(ExceptionHandlerPathFeature?.Error, string.Empty);

            return(StatusCode(code));
        }
コード例 #2
0
        /// <summary>
        /// Displays a not-found page.
        /// </summary>
        /// <returns>A not-found page.</returns>
        private ActionResult UserNotFound()
        {
            var metadata = new PageMetadata
            {
                Title = ErrorTitle
            };

            var message = Localize("Identity.UserNotFound");

            return(View("UserMessage", GetPageViewModel(metadata, message: message, messageType: MessageType.Error)));
        }
コード例 #3
0
        /// <summary>
        /// Displays the user profile.
        /// </summary>
        /// <returns>Either a user profile page, or a not-found page.</returns>
        private async Task <ActionResult> GetProfileAsync()
        {
            var userName = HttpContext.User?.Identity?.Name;

            if (!string.IsNullOrEmpty(userName))
            {
                var profileResult = await _profileManager.GetProfileAsync(userName);

                var metadata = new PageMetadata
                {
                    Title = profileResult.Data.PageTitle
                };

                if (profileResult.Success)
                {
                    var model = GetPageViewModel(metadata, profileResult.Data.UserViewModel);

                    return(View(model));
                }
            }

            return(UserNotFound());
        }
コード例 #4
0
        public async Task <ActionResult> Index(PageViewModel <IUserViewModel> uploadModel)
        {
            var message = ConcatenateContactAdmin("General.Error");

            if (ModelState.IsValid)
            {
                var profileResult = await _profileManager.PostProfileAsync(uploadModel.Data);

                switch (profileResult.ResultState)
                {
                case PostProfileResultState.UserNotFound:
                    message = ConcatenateContactAdmin("Identity.UserNotFound");
                    break;

                case PostProfileResultState.UserNotMapped:
                case PostProfileResultState.UserNotUpdated:
                    message = ConcatenateContactAdmin("Identity.Profile.UserNotUpdated");
                    break;

                case PostProfileResultState.UserUpdated:
                    message = Localize("Identity.Profile.UserUpdated");
                    break;
                }

                var metadata = new PageMetadata
                {
                    Title = profileResult.Data.PageTitle ?? ErrorTitle
                };

                var model = GetPageViewModel(metadata, profileResult.Data.UserViewModel, message);

                return(View(model));
            }

            return(await GetProfileAsync());
        }