Esempio n. 1
0
        public virtual ActionResult BlogPost(int blogPostId)
        {
            if (!_blogSettings.Enabled)
            {
                return(RedirectToRoute("HomePage"));
            }

            var blogPost = _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());
            }

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

            var model = new BlogPostModel();

            _blogModelFactory.PrepareBlogPostModel(model, blogPost, true);

            return(View(model));
        }
Esempio n. 2
0
        public virtual IActionResult BlogPostCreate()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageBlog))
            {
                return(AccessDeniedView());
            }

            //prepare model
            var model = _blogModelFactory.PrepareBlogPostModel(new BlogPostModel(), null);

            return(View(model));
        }
Esempio n. 3
0
        public virtual IActionResult BlogPostCreate()
        {
            bool isAuthorized = _authorizationService.AuthorizeAsync(User, GetCurrentUserAsync(), CustomerOperations.Create).Result.Succeeded;

            if (!isAuthorized)
            {
                return(AccessDeniedView());
            }
            //prepare model
            BlogPostModel model = _blogModelFactory.PrepareBlogPostModel(new BlogPostModel(), null);

            return(View(model));
        }
Esempio n. 4
0
        public virtual ActionResult BlogPost(int blogPostId)
        {
            var blogPost = _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"));
            }

            var model = new BlogPostModel();

            _blogModelFactory.PrepareBlogPostModel(model, blogPost, true);

            return(View(model));
        }
        public virtual IActionResult BlogPost(int blogPostId)
        {
            if (!_blogSettings.Enabled)
            {
                return(RedirectToRoute("Homepage"));
            }

            var blogPost = _blogService.GetBlogPostById(blogPostId);

            if (blogPost == null)
            {
                return(InvokeHttp404());
            }

            var notAvailable =
                //availability dates
                !_blogService.BlogPostIsAvailable(blogPost) ||
                //Store mapping
                !_storeMappingService.Authorize(blogPost);
            //Check whether the current user has a "Manage blog" permission (usually a store owner)
            //We should allows him (her) to use "Preview" functionality
            var hasAdminAccess = _permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel) && _permissionService.Authorize(StandardPermissionProvider.ManageBlog);

            if (notAvailable && !hasAdminAccess)
            {
                return(InvokeHttp404());
            }

            //display "edit" (manage) link
            if (hasAdminAccess)
            {
                DisplayEditLink(Url.Action("BlogPostEdit", "Blog", new { id = blogPost.Id, area = AreaNames.Admin }));
            }

            var model = new BlogPostModel();

            _blogModelFactory.PrepareBlogPostModel(model, blogPost, true);

            return(View(model));
        }
Esempio n. 6
0
        public virtual IActionResult BlogPost(int blogPostId)
        {
            if (!_blogSettings.Enabled)
            {
                return(RedirectToRoute("HomePage"));
            }

            var blogPost = _blogService.GetBlogPostById(blogPostId);

            if (blogPost == null)
            {
                return(RedirectToRoute("HomePage"));
            }

            var hasAdminAccess = _permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel) && _permissionService.Authorize(StandardPermissionProvider.ManageBlog);

            //access to Blog preview
            if (!blogPost.IsAvailable() && !hasAdminAccess)
            {
                return(RedirectToRoute("HomePage"));
            }

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

            //display "edit" (manage) link
            if (hasAdminAccess)
            {
                DisplayEditLink(Url.Action("Edit", "Blog", new { id = blogPost.Id, area = AreaNames.Admin }));
            }

            var model = new BlogPostModel();

            _blogModelFactory.PrepareBlogPostModel(model, blogPost, true);

            return(View(model));
        }