Ejemplo n.º 1
0
        public virtual async Task <IActionResult> BlogPost(string blogPostId,
                                                           [FromServices] IStoreMappingService storeMappingService,
                                                           [FromServices] IPermissionService permissionService)
        {
            if (!_blogSettings.Enabled)
            {
                return(RedirectToRoute("HomePage"));
            }

            var blogPost = await _blogService.GetBlogPostById(blogPostId);

            if (blogPost == null ||
                (blogPost.StartDateUtc.HasValue && blogPost.StartDateUtc.Value >= DateTime.UtcNow) ||
                (blogPost.EndDateUtc.HasValue && blogPost.EndDateUtc.Value <= DateTime.UtcNow))
            {
                return(RedirectToRoute("HomePage"));
            }

            //Store mapping
            if (!storeMappingService.Authorize(blogPost))
            {
                return(InvokeHttp404());
            }

            var model = new BlogPostModel();
            await _blogViewModelService.PrepareBlogPostModel(model, blogPost, true);

            //display "edit" (manage) link
            if (await permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel) && await permissionService.Authorize(StandardPermissionProvider.ManageBlog))
            {
                DisplayEditLink(Url.Action("Edit", "Blog", new { id = blogPost.Id, area = "Admin" }));
            }

            return(View(model));
        }
        public IActionResult Create()
        {
            ViewBag.AllLanguages = _languageService.GetAllLanguages(true);
            var model = _blogViewModelService.PrepareBlogPostModel();

            //locales
            AddLocales(_languageService, model.Locales);

            return(View(model));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create()
        {
            ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);

            var model = await _blogViewModelService.PrepareBlogPostModel();

            //locales
            await AddLocales(_languageService, model.Locales);

            return(View(model));
        }