Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

ARCH-001 Phase 14: Blog controller/service consolidation (Admin/Store) (#808)

Krzysztof Pajak2da0b6b81fd9
diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/BaseBlogControllerTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/BaseBlogControllerTests.cs
new file mode 100644
index 000000000..ee3c142cf
--- /dev/null
+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/BaseBlogControllerTests.cs
@@ -0,0 +1,477 @@
+using Grand.Business.Core.Interfaces.Cms;
+using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Business.Core.Interfaces.Common.Stores;
+using Grand.Domain.Blogs;
+using Grand.Domain.Seo;
+using Grand.Infrastructure.Mapper;
+using Grand.Mapping;
+using Grand.Web.AdminShared.Controllers;
+using Grand.Web.AdminShared.Interfaces;
+using Grand.Web.AdminShared.Mapper;
+using Grand.Web.AdminShared.Models.Blogs;
+using Grand.Web.AdminShared.Models.Common;
+using Grand.Web.Common.DataSource;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Routing;
+using Microsoft.AspNetCore.Mvc.ViewFeatures;
+using Microsoft.Extensions.Logging;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+
+namespace Grand.Web.Admin.Tests.Controllers;
+
+// Characterization tests for the merged Blog access-check behavior (ARCH-001 Blog consolidation).
+[TestClass]
+public class BaseBlogControllerTests
+{
+ private class TestBlogController(
+ IBlogService blogService,
+ IBlogViewModelService blogViewModelService,
+ ILanguageService languageService,
+ ITranslationService translationService,
+ IStoreService storeService,
+ IDateTimeService dateTimeService,
+ IPictureViewModelService pictureViewModelService,
+ SeoSettings seoSettings,
+ IAdminDataScope<BlogPost> postScope,
+ IAdminDataScope<BlogCategory> categoryScope)
+ : BaseBlogController(blogService, blogViewModelService, languageService, translationService,
+ storeService, dateTimeService, pictureViewModelService, seoSettings, postScope, categoryScope);
+
+ private TestBlogController _controller;
+ private Mock<IBlogService> _blogServiceMock;
+ private Mock<IBlogViewModelService> _blogViewModelServiceMock;
+ private Mock<ITranslationService> _translationServiceMock;
+ private Mock<IAdminDataScope<BlogPost>> _postScopeMock;
+ private Mock<IAdminDataScope<BlogCategory>> _categoryScopeMock;
+
+ [TestInitialize]
+ public void Setup()
+ {
+ var mapperConfig = new MapperConfiguration(cfg =>
+ {
+ cfg.AddProfile<BlogPostProfile>();
+ cfg.AddProfile<BlogCategoryProfile>();
+ });
+ AutoMapperConfig.Init(mapperConfig);
+
+ _blogServiceMock = new Mock<IBlogService>();
+ _blogViewModelServiceMock = new Mock<IBlogViewModelService>();
+ _translationServiceMock = new Mock<ITranslationService>();
+ _translationServiceMock.Setup(t => t.GetResource(It.IsAny<string>())).Returns("resource");
+
+ _postScopeMock = new Mock<IAdminDataScope<BlogPost>>();
+ _postScopeMock.Setup(s => s.DefaultStoreId).Returns((string)null);
+ _categoryScopeMock = new Mock<IAdminDataScope<BlogCategory>>();
+ _categoryScopeMock.Setup(s => s.DefaultStoreId).Returns((string)null);
+
+ var languageServiceMock = new Mock<ILanguageService>();
+ languageServiceMock.Setup(l => l.GetAllLanguages(true, It.IsAny<string>()))
+ .ReturnsAsync(new List<Grand.Domain.Localization.Language>());
+
+ _controller = new TestBlogController(
+ _blogServiceMock.Object,
+ _blogViewModelServiceMock.Object,
+ languageServiceMock.Object,
+ _translationServiceMock.Object,
+ new Mock<IStoreService>().Object,
+ new Mock<IDateTimeService>().Object,
+ new Mock<IPictureViewModelService>().Object,
+ new SeoSettings(),
+ _postScopeMock.Object,
+ _categoryScopeMock.Object);
+
+ var httpContext = new DefaultHttpContext();
+ var loggerFactoryMock = new Mock<ILoggerFactory>();
+ loggerFactoryMock.Setup(l => l.CreateLogger(It.IsAny<string>())).Returns(new Mock<ILogger>().Object);
+ var urlHelperFactoryMock = new Mock<IUrlHelperFactory>();
+ urlHelperFactoryMock.Setup(f => f.GetUrlHelper(It.IsAny<ActionContext>())).Returns(new Mock<IUrlHelper>().Object);
+ var requestServicesMock = new Mock<IServiceProvider>();
+ requestServicesMock.Setup(s => s.GetService(typeof(ILoggerFactory))).Returns(loggerFactoryMock.Object);
+ requestServicesMock.Setup(s => s.GetService(typeof(IUrlHelperFactory))).Returns(urlHelperFactoryMock.Object);
+ httpContext.RequestServices = requestServicesMock.Object;
+ _controller.ControllerContext = new ControllerContext { HttpContext = httpContext };
+ _controller.TempData = new TempDataDictionary(httpContext, new Mock<ITempDataProvider>().Object);
+ }
+
+ [TestMethod]
+ public async Task EditGet_PostNotFound_RedirectsToList()
+ {
+ _blogServiceMock.Setup(b => b.GetBlogPostById("missing")).ReturnsAsync((BlogPost)null);
+
+ var result = await _controller.Edit("missing");
+
+ var redirect = result as RedirectToActionResult;
+ Assert.IsNotNull(redirect);
+ Assert.AreEqual("List", redirect.ActionName);
+ _postScopeMock.Verify(s => s.CanView(It.IsAny<BlogPost>()), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task EditGet_ScopeDeniesView_RedirectsToList()
+ {
+ var post = new BlogPost { Id = "p1" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.CanView(post)).ReturnsAsync(false);
+
+ var result = await _controller.Edit("p1");
+
+ var redirect = result as RedirectToActionResult;
+ Assert.IsNotNull(redirect);
+ Assert.AreEqual("List", redirect.ActionName);
+ }
+
+ [TestMethod]
+ public async Task EditGet_ScopeAllowsView_ReturnsViewWithModel()
+ {
+ var post = new BlogPost { Id = "p1", Title = "Hello" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.CanView(post)).ReturnsAsync(true);
+
+ var result = await _controller.Edit("p1");
+
+ var view = result as ViewResult;
+ Assert.IsNotNull(view);
+ Assert.AreEqual("Hello", ((BlogPostModel)view.Model).Title);
+ }
+
+ [TestMethod]
+ public async Task EditPost_ScopeDeniesAccess_RedirectsToEdit()
+ {
+ var post = new BlogPost { Id = "p1" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(false);
+
+ var result = await _controller.Edit(new BlogPostModel { Id = "p1" }, false);
+
+ var redirect = result as RedirectToActionResult;
+ Assert.IsNotNull(redirect);
+ Assert.AreEqual("Edit", redirect.ActionName);
+ _blogViewModelServiceMock.Verify(v => v.UpdateBlogPostModel(It.IsAny<BlogPostModel>(), It.IsAny<BlogPost>()), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task Delete_ScopeDeniesAccess_RedirectsToEditWithoutDeleting()
+ {
+ var post = new BlogPost { Id = "p1" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(false);
+
+ var result = await _controller.Delete("p1");
+
+ var redirect = result as RedirectToActionResult;
+ Assert.IsNotNull(redirect);
+ Assert.AreEqual("Edit", redirect.ActionName);
+ Assert.AreEqual("p1", redirect.RouteValues["id"]);
+ _blogServiceMock.Verify(b => b.DeleteBlogPost(It.IsAny<BlogPost>()), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task CreatePost_StoreScoped_ForcesModelStores()
+ {
+ _postScopeMock.Setup(s => s.DefaultStoreId).Returns("store-1");
+ var inserted = new BlogPost { Id = "new-1" };
+ _blogViewModelServiceMock
+ .Setup(v => v.InsertBlogPostModel(It.IsAny<BlogPostModel>()))
+ .ReturnsAsync(inserted)
+ .Callback<BlogPostModel>(m => Assert.AreEqual("store-1", m.Stores.Single()));
+
+ await _controller.Create(new BlogPostModel { Title = "N" }, false);
+
+ _blogViewModelServiceMock.Verify(v => v.InsertBlogPostModel(It.IsAny<BlogPostModel>()), Times.Once);
+ }
+
+ [TestMethod]
+ public async Task CreatePost_GlobalScoped_LeavesModelStoresUntouched()
+ {
+ _postScopeMock.Setup(s => s.DefaultStoreId).Returns((string)null);
+ var inserted = new BlogPost { Id = "new-1" };
+ var submitted = new BlogPostModel { Title = "N", Stores = ["explicit-store"] };
+ _blogViewModelServiceMock
+ .Setup(v => v.InsertBlogPostModel(It.IsAny<BlogPostModel>()))
+ .ReturnsAsync(inserted)
+ .Callback<BlogPostModel>(m => Assert.AreEqual("explicit-store", m.Stores.Single()));
+
+ await _controller.Create(submitted, false);
+
+ _blogViewModelServiceMock.Verify(v => v.InsertBlogPostModel(It.IsAny<BlogPostModel>()), Times.Once);
+ }
+
+ [TestMethod]
+ public async Task PicturePopupGet_ScopeDeniesAccess_ReturnsDeniedContent()
+ {
+ var post = new BlogPost { Id = "p1", PictureId = "pic-1" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(false);
+
+ var result = await _controller.PicturePopup("p1");
+
+ var content = result as ContentResult;
+ Assert.IsNotNull(content);
+ Assert.AreEqual("You don't have access to this blog post", content.Content);
+ }
+
+ [TestMethod]
+ public async Task PicturePopupGet_PostNotFound_ReturnsNotExistContent()
+ {
+ _blogServiceMock.Setup(b => b.GetBlogPostById("missing")).ReturnsAsync((BlogPost)null);
+
+ var result = await _controller.PicturePopup("missing");
+
+ var content = result as ContentResult;
+ Assert.IsNotNull(content);
+ Assert.AreEqual("Blog post not exist", content.Content);
+ _postScopeMock.Verify(s => s.HasAccess(It.IsAny<BlogPost>()), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task PicturePopupPost_ScopeDeniesAccess_ReturnsDeniedContent()
+ {
+ var post = new BlogPost { Id = "p1", PictureId = "pic-1" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(false);
+
+ var model = new PictureModel { ObjectId = "p1", Id = "pic-1" };
+ var result = await _controller.PicturePopup(model);
+
+ var content = result as ContentResult;
+ Assert.IsNotNull(content);
+ Assert.AreEqual("You don't have access to this blog post", content.Content);
+ }
+
+ [TestMethod]
+ public async Task CategoryListPost_ForcesScopeDefaultStoreId()
+ {
+ _categoryScopeMock.Setup(s => s.DefaultStoreId).Returns("store-1");
+ _blogServiceMock.Setup(b => b.GetAllBlogCategories("store-1")).ReturnsAsync(new List<BlogCategory>());
+
+ await _controller.CategoryList(new DataSourceRequest { Page = 1, PageSize = 10 });
+
+ _blogServiceMock.Verify(b => b.GetAllBlogCategories("store-1"), Times.Once);
+ }
+
+ [TestMethod]
+ public async Task CategoryListPost_GlobalScope_PassesEmptyString()
+ {
+ _categoryScopeMock.Setup(s => s.DefaultStoreId).Returns((string)null);
+ _blogServiceMock.Setup(b => b.GetAllBlogCategories("")).ReturnsAsync(new List<BlogCategory>());
+
+ await _controller.CategoryList(new DataSourceRequest { Page = 1, PageSize = 10 });
+
+ _blogServiceMock.Verify(b => b.GetAllBlogCategories(""), Times.Once);
+ }
+
+ [TestMethod]
+ public async Task CategoryEditGet_ScopeDeniesAccess_RedirectsToCategoryList()
+ {
+ var category = new BlogCategory { Id = "c1" };
+ _blogServiceMock.Setup(b => b.GetBlogCategoryById("c1")).ReturnsAsync(category);
+ _categoryScopeMock.Setup(s => s.HasAccess(category)).ReturnsAsync(false);
+
+ var result = await _controller.CategoryEdit("c1");
+
+ var redirect = result as RedirectToActionResult;
+ Assert.IsNotNull(redirect);
+ Assert.AreEqual("CategoryList", redirect.ActionName);
+ }
+
+ [TestMethod]
+ public async Task CategoryDelete_ScopeDeniesAccess_RedirectsToCategoryListWithoutDeleting()
+ {
+ var category = new BlogCategory { Id = "c1" };
+ _blogServiceMock.Setup(b => b.GetBlogCategoryById("c1")).ReturnsAsync(category);
+ _categoryScopeMock.Setup(s => s.HasAccess(category)).ReturnsAsync(false);
+
+ var result = await _controller.CategoryDelete("c1");
+
+ var redirect = result as RedirectToActionResult;
+ Assert.IsNotNull(redirect);
+ Assert.AreEqual("CategoryList", redirect.ActionName);
+ _blogServiceMock.Verify(b => b.DeleteBlogCategory(It.IsAny<BlogCategory>()), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task CategoryPostList_ScopeDeniesAccess_ReturnsKendoError()
+ {
+ var category = new BlogCategory { Id = "c1" };
+ _blogServiceMock.Setup(b => b.GetBlogCategoryById("c1")).ReturnsAsync(category);
+ _categoryScopeMock.Setup(s => s.HasAccess(category)).ReturnsAsync(false);
+
+ var result = await _controller.CategoryPostList("c1");
+
+ var json = result as JsonResult;
+ Assert.IsNotNull(json);
+ var gridModel = (DataSourceResult)json.Value;
+ Assert.IsNotNull(gridModel.Errors);
+ }
+
+ [TestMethod]
+ public async Task BlogPostAddPopupInsert_SkipsInaccessiblePostsButLinksAccessibleOnes()
+ {
+ // Store's original AddSelectedPostsToBlogCategory/AddPostToBlogCategoryIfValid skip-not-fail
+ // semantics: an accessible category linking one accessible and one inaccessible post must
+ // link only the accessible one, not fail the whole request.
+ var category = new BlogCategory { Id = "c1", BlogPosts = new List<Grand.Domain.Blogs.BlogCategoryPost>() };
+ _blogServiceMock.Setup(b => b.GetBlogCategoryById("c1")).ReturnsAsync(category);
+ _categoryScopeMock.Setup(s => s.HasAccess(category)).ReturnsAsync(true);
+
+ var accessiblePost = new BlogPost { Id = "accessible-1" };
+ var inaccessiblePost = new BlogPost { Id = "inaccessible-1" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("accessible-1")).ReturnsAsync(accessiblePost);
+ _blogServiceMock.Setup(b => b.GetBlogPostById("inaccessible-1")).ReturnsAsync(inaccessiblePost);
+ _postScopeMock.Setup(s => s.HasAccess(accessiblePost)).ReturnsAsync(true);
+ _postScopeMock.Setup(s => s.HasAccess(inaccessiblePost)).ReturnsAsync(false);
+
+ var model = new AddBlogPostCategoryModel { CategoryId = "c1", SelectedBlogPostIds = ["accessible-1", "inaccessible-1"] };
+ await _controller.BlogPostAddPopup(model);
+
+ Assert.AreEqual(1, category.BlogPosts.Count);
+ Assert.AreEqual("accessible-1", category.BlogPosts[0].BlogPostId);
+ _blogServiceMock.Verify(b => b.UpdateBlogCategory(category), Times.Once);
+ }
+
+ [TestMethod]
+ public async Task BlogPostAddPopupInsert_ScopeDeniesCategoryAccess_LinksNothing()
+ {
+ var category = new BlogCategory { Id = "c1", BlogPosts = new List<Grand.Domain.Blogs.BlogCategoryPost>() };
+ _blogServiceMock.Setup(b => b.GetBlogCategoryById("c1")).ReturnsAsync(category);
+ _categoryScopeMock.Setup(s => s.HasAccess(category)).ReturnsAsync(false);
+
+ var model = new AddBlogPostCategoryModel { CategoryId = "c1", SelectedBlogPostIds = ["post-1"] };
+ await _controller.BlogPostAddPopup(model);
+
+ Assert.AreEqual(0, category.BlogPosts.Count);
+ _blogServiceMock.Verify(b => b.UpdateBlogCategory(It.IsAny<BlogCategory>()), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task BlogPostAddPopupList_ForcesScopeDefaultStoreId()
+ {
+ _categoryScopeMock.Setup(s => s.DefaultStoreId).Returns("store-1");
+ _blogServiceMock
+ .Setup(b => b.GetAllBlogPosts("store-1", null, null, 0, 10, false, null, null, ""))
+ .ReturnsAsync(new Grand.Domain.PagedList<BlogPost>(new List<BlogPost>(), 0, 10));
+
+ var model = new AddBlogPostCategoryModel { SearchStoreId = "attacker-supplied" };
+ await _controller.BlogPostAddPopupList(new DataSourceRequest { Page = 1, PageSize = 10 }, model);
+
+ Assert.AreEqual("store-1", model.SearchStoreId);
+ }
+
+ [TestMethod]
+ public async Task CommentDelete_ScopeDeniesAccess_ReturnsKendoErrorWithoutDeleting()
+ {
+ var comment = new Grand.Domain.Blogs.BlogComment { Id = "cm1", BlogPostId = "p1" };
+ var post = new BlogPost { Id = "p1" };
+ _blogServiceMock.Setup(b => b.GetBlogCommentById("cm1")).ReturnsAsync(comment);
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(false);
+
+ var result = await _controller.CommentDelete("cm1");
+
+ var json = result as JsonResult;
+ Assert.IsNotNull(json);
+ var gridModel = (DataSourceResult)json.Value;
+ Assert.IsNotNull(gridModel.Errors);
+ _blogServiceMock.Verify(b => b.DeleteBlogComment(It.IsAny<Grand.Domain.Blogs.BlogComment>()), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task CommentDelete_BlogPostNoLongerExists_ReturnsKendoErrorWithoutDeleting()
+ {
+ var comment = new Grand.Domain.Blogs.BlogComment { Id = "cm1", BlogPostId = "missing" };
+ _blogServiceMock.Setup(b => b.GetBlogCommentById("cm1")).ReturnsAsync(comment);
+ _blogServiceMock.Setup(b => b.GetBlogPostById("missing")).ReturnsAsync((BlogPost)null);
+
+ var result = await _controller.CommentDelete("cm1");
+
+ var json = result as JsonResult;
+ Assert.IsNotNull(json);
+ var gridModel = (DataSourceResult)json.Value;
+ Assert.IsNotNull(gridModel.Errors);
+ _postScopeMock.Verify(s => s.HasAccess(It.IsAny<BlogPost>()), Times.Never);
+ _blogServiceMock.Verify(b => b.DeleteBlogComment(It.IsAny<Grand.Domain.Blogs.BlogComment>()), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task Products_ScopeDeniesAccess_ReturnsKendoError()
+ {
+ var post = new BlogPost { Id = "p1" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(false);
+
+ var result = await _controller.Products("p1", new DataSourceRequest { Page = 1, PageSize = 10 });
+
+ var json = result as JsonResult;
+ Assert.IsNotNull(json);
+ var gridModel = (DataSourceResult)json.Value;
+ Assert.IsNotNull(gridModel.Errors);
+ }
+
+ [TestMethod]
+ public async Task ProductAddPopupList_ForcesScopeDefaultStoreId()
+ {
+ _postScopeMock.Setup(s => s.DefaultStoreId).Returns("store-1");
+ _blogViewModelServiceMock
+ .Setup(v => v.PrepareProductModel(It.IsAny<BlogProductModel.AddProductModel>(), 1, 10))
+ .ReturnsAsync((new List<Grand.Web.AdminShared.Models.Catalog.ProductModel>(), 0));
+
+ var model = new BlogProductModel.AddProductModel { SearchStoreId = "attacker-supplied" };
+ await _controller.ProductAddPopupList(new DataSourceRequest { Page = 1, PageSize = 10 }, model);
+
+ Assert.AreEqual("store-1", model.SearchStoreId);
+ }
+
+ [TestMethod]
+ public async Task UpdateProduct_ScopeDeniesAccess_ReturnsKendoErrorWithoutUpdating()
+ {
+ var post = new BlogPost { Id = "p1" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(false);
+
+ var result = await _controller.UpdateProduct("p1", new BlogProductModel { Id = "bp1" });
+
+ var json = result as JsonResult;
+ Assert.IsNotNull(json);
+ var gridModel = (DataSourceResult)json.Value;
+ Assert.IsNotNull(gridModel.Errors);
+ _blogViewModelServiceMock.Verify(v => v.UpdateProductModel(It.IsAny<BlogProductModel>()), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task DeleteProduct_ScopeDeniesAccess_ReturnsKendoErrorWithoutDeleting()
+ {
+ var bp = new Grand.Domain.Blogs.BlogProduct { Id = "bp1", BlogPostId = "p1" };
+ var post = new BlogPost { Id = "p1" };
+ _blogServiceMock.Setup(b => b.GetBlogProductById("bp1")).ReturnsAsync(bp);
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(false);
+
+ var result = await _controller.DeleteProduct("bp1");
+
+ var json = result as JsonResult;
+ Assert.IsNotNull(json);
+ var gridModel = (DataSourceResult)json.Value;
+ Assert.IsNotNull(gridModel.Errors);
+ _blogViewModelServiceMock.Verify(v => v.DeleteProductModel(It.IsAny<string>()), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task CommentDelete_ScopeGrantsAccess_DeletesAndUpdatesCommentCount()
+ {
+ var comment = new Grand.Domain.Blogs.BlogComment { Id = "cm1", BlogPostId = "p1" };
+ var post = new BlogPost { Id = "p1", CommentCount = 3 };
+ _blogServiceMock.Setup(b => b.GetBlogCommentById("cm1")).ReturnsAsync(comment);
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(true);
+ _blogServiceMock.Setup(b => b.GetBlogCommentsByBlogPostId("p1"))
+ .ReturnsAsync(new List<Grand.Domain.Blogs.BlogComment> { new(), new() });
+
+ await _controller.CommentDelete("cm1");
+
+ _blogServiceMock.Verify(b => b.DeleteBlogComment(comment), Times.Once);
+ _blogServiceMock.Verify(b => b.UpdateBlogPost(It.Is<BlogPost>(p => p.CommentCount == 2)), Times.Once);
+ }
+}
diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/BlogControllerTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/BlogControllerTests.cs
new file mode 100644
index 000000000..5b5e0fdbe
--- /dev/null
+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/BlogControllerTests.cs
@@ -0,0 +1,31 @@
+using System.Reflection;
+using Grand.Web.Admin.Controllers;
+using Grand.Web.AdminShared.Controllers;
+using Grand.Web.Common.Filters;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Grand.Web.Admin.Tests.Controllers;
+
+[TestClass]
+public class BlogControllerTests
+{
+ [TestMethod]
+ public void BlogController_IsThinSubclassOfBaseBlogController()
+ {
+ Assert.IsTrue(typeof(BlogController).IsSubclassOf(typeof(BaseBlogController)));
+ }
+
+ [TestMethod]
+ public void BlogController_HasRequiredHostAttributes()
+ {
+ var type = typeof(BlogController);
+ Assert.IsTrue(type.IsDefined(typeof(AreaAttribute), inherit: false), "[Area] missing");
+ Assert.IsTrue(type.IsDefined(typeof(AuthorizeAdminAttribute), inherit: false), "[AuthorizeAdmin] missing");
+ Assert.IsTrue(type.IsDefined(typeof(AuthorizeMenuAttribute), inherit: false), "[AuthorizeMenu] missing");
+ Assert.IsTrue(type.IsDefined(typeof(AutoValidateAntiforgeryTokenAttribute), inherit: false), "[AutoValidateAntiforgeryToken] missing");
+
+ var area = type.GetCustomAttribute<AreaAttribute>()!;
+ Assert.AreEqual("Admin", area.RouteValue);
+ }
+}
diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/RoutedBlogCategoryDataScopeTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/RoutedBlogCategoryDataScopeTests.cs
new file mode 100644
index 000000000..ef73e7cbb
--- /dev/null
+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/RoutedBlogCategoryDataScopeTests.cs
@@ -0,0 +1,64 @@
+using Grand.Domain.Blogs;
+using Grand.Web.AdminShared.Interfaces;
+using Grand.Web.AdminShared.Services;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Routing;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+
+namespace Grand.Web.Admin.Tests.Controllers;
+
+[TestClass]
+public class RoutedBlogCategoryDataScopeTests
+{
+ private static RoutedBlogCategoryDataScope Build(string? area)
+ {
+ var httpContext = new DefaultHttpContext();
+ if (area != null)
+ httpContext.Request.RouteValues = new RouteValueDictionary { ["area"] = area };
+
+ var httpContextAccessorMock = new Mock<IHttpContextAccessor>();
+ httpContextAccessorMock.Setup(a => a.HttpContext).Returns(httpContext);
+
+ var global = new GlobalAdminDataScope<BlogCategory>();
+ var store = new StoreAdminDataScope<BlogCategory>(BuildContextAccessor());
+ return new RoutedBlogCategoryDataScope(httpContextAccessorMock.Object, global, store);
+ }
+
+ private static Grand.Infrastructure.IContextAccessor BuildContextAccessor()
+ {
+ var workContext = new Mock<Grand.Infrastructure.IWorkContext>();
+ workContext.Setup(w => w.CurrentCustomer).Returns(new Grand.Domain.Customers.Customer { StaffStoreId = "store-1" });
+ var contextAccessorMock = new Mock<Grand.Infrastructure.IContextAccessor>();
+ contextAccessorMock.Setup(c => c.WorkContext).Returns(workContext.Object);
+ return contextAccessorMock.Object;
+ }
+
+ [TestMethod]
+ public void DefaultStoreId_AdminArea_ResolvesToGlobalScope()
+ {
+ var routed = Build("Admin");
+ Assert.IsNull(routed.DefaultStoreId);
+ }
+
+ [TestMethod]
+ public void DefaultStoreId_StoreArea_ResolvesToStoreScope()
+ {
+ var routed = Build("Store");
+ Assert.AreEqual("store-1", routed.DefaultStoreId);
+ }
+
+ [TestMethod]
+ public void DefaultStoreId_VendorArea_ThrowsFailClosed()
+ {
+ var routed = Build("Vendor");
+ Assert.ThrowsExactly<InvalidOperationException>(() => _ = routed.DefaultStoreId);
+ }
+
+ [TestMethod]
+ public void DefaultStoreId_MissingArea_ThrowsFailClosed()
+ {
+ var routed = Build(null);
+ Assert.ThrowsExactly<InvalidOperationException>(() => _ = routed.DefaultStoreId);
+ }
+}
diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/RoutedBlogPostDataScopeTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/RoutedBlogPostDataScopeTests.cs
new file mode 100644
index 000000000..066b512ad
--- /dev/null
+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/RoutedBlogPostDataScopeTests.cs
@@ -0,0 +1,64 @@
+using Grand.Domain.Blogs;
+using Grand.Web.AdminShared.Interfaces;
+using Grand.Web.AdminShared.Services;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Routing;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+
+namespace Grand.Web.Admin.Tests.Controllers;
+
+[TestClass]
+public class RoutedBlogPostDataScopeTests
+{
+ private static RoutedBlogPostDataScope Build(string? area)
+ {
+ var httpContext = new DefaultHttpContext();
+ if (area != null)
+ httpContext.Request.RouteValues = new RouteValueDictionary { ["area"] = area };
+
+ var httpContextAccessorMock = new Mock<IHttpContextAccessor>();
+ httpContextAccessorMock.Setup(a => a.HttpContext).Returns(httpContext);
+
+ var global = new GlobalAdminDataScope<BlogPost>();
+ var store = new StoreAdminDataScope<BlogPost>(BuildContextAccessor());
+ return new RoutedBlogPostDataScope(httpContextAccessorMock.Object, global, store);
+ }
+
+ private static Grand.Infrastructure.IContextAccessor BuildContextAccessor()
+ {
+ var workContext = new Mock<Grand.Infrastructure.IWorkContext>();
+ workContext.Setup(w => w.CurrentCustomer).Returns(new Grand.Domain.Customers.Customer { StaffStoreId = "store-1" });
+ var contextAccessorMock = new Mock<Grand.Infrastructure.IContextAccessor>();
+ contextAccessorMock.Setup(c => c.WorkContext).Returns(workContext.Object);
+ return contextAccessorMock.Object;
+ }
+
+ [TestMethod]
+ public void DefaultStoreId_AdminArea_ResolvesToGlobalScope()
+ {
+ var routed = Build("Admin");
+ Assert.IsNull(routed.DefaultStoreId);
+ }
+
+ [TestMethod]
+ public void DefaultStoreId_StoreArea_ResolvesToStoreScope()
+ {
+ var routed = Build("Store");
+ Assert.AreEqual("store-1", routed.DefaultStoreId);
+ }
+
+ [TestMethod]
+ public void DefaultStoreId_VendorArea_ThrowsFailClosed()
+ {
+ var routed = Build("Vendor");
+ Assert.ThrowsExactly<InvalidOperationException>(() => _ = routed.DefaultStoreId);
+ }
+
+ [TestMethod]
+ public void DefaultStoreId_MissingArea_ThrowsFailClosed()
+ {
+ var routed = Build(null);
+ Assert.ThrowsExactly<InvalidOperationException>(() => _ = routed.DefaultStoreId);
+ }
+}
diff --git a/src/Tests/Grand.Web.Store.Tests/Controllers/BlogControllerTests.cs b/src/Tests/Grand.Web.Store.Tests/Controllers/BlogControllerTests.cs
new file mode 100644
index 000000000..c91d9336f
--- /dev/null
+++ b/src/Tests/Grand.Web.Store.Tests/Controllers/BlogControllerTests.cs
@@ -0,0 +1,246 @@
+using System.Reflection;
+using Grand.Business.Core.Interfaces.Cms;
+using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Business.Core.Interfaces.Common.Stores;
+using Grand.Domain.Blogs;
+using Grand.Domain.Seo;
+using Grand.Infrastructure.Mapper;
+using Grand.Mapping;
+using Grand.Web.AdminShared.Controllers;
+using Grand.Web.AdminShared.Interfaces;
+using Grand.Web.AdminShared.Mapper;
+using Grand.Web.Common.Filters;
+using Grand.Web.Store.Controllers;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Routing;
+using Microsoft.AspNetCore.Mvc.ViewFeatures;
+using Microsoft.Extensions.Logging;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+
+namespace Grand.Web.Store.Tests.Controllers;
+
+[TestClass]
+public class BlogControllerTests
+{
+ private BlogController _controller;
+ private Mock<IBlogService> _blogServiceMock;
+ private Mock<IAdminDataScope<BlogPost>> _postScopeMock;
+
+ [TestInitialize]
+ public void Setup()
+ {
+ var mapperConfig = new MapperConfiguration(cfg =>
+ {
+ cfg.AddProfile<BlogPostProfile>();
+ cfg.AddProfile<BlogCategoryProfile>();
+ });
+ AutoMapperConfig.Init(mapperConfig);
+
+ _blogServiceMock = new Mock<IBlogService>();
+ _postScopeMock = new Mock<IAdminDataScope<BlogPost>>();
+
+ _controller = new BlogController(
+ _blogServiceMock.Object,
+ new Mock<IBlogViewModelService>().Object,
+ new Mock<ILanguageService>().Object,
+ new Mock<ITranslationService>().Object,
+ new Mock<IStoreService>().Object,
+ new Mock<IDateTimeService>().Object,
+ new Mock<IPictureViewModelService>().Object,
+ new SeoSettings(),
+ _postScopeMock.Object,
+ new Mock<IAdminDataScope<BlogCategory>>().Object);
+
+ var httpContext = new DefaultHttpContext();
+ var loggerFactoryMock = new Mock<ILoggerFactory>();
+ loggerFactoryMock.Setup(l => l.CreateLogger(It.IsAny<string>())).Returns(new Mock<ILogger>().Object);
+ var urlHelperFactoryMock = new Mock<IUrlHelperFactory>();
+ urlHelperFactoryMock.Setup(f => f.GetUrlHelper(It.IsAny<ActionContext>())).Returns(new Mock<IUrlHelper>().Object);
+ var requestServicesMock = new Mock<IServiceProvider>();
+ requestServicesMock.Setup(s => s.GetService(typeof(ILoggerFactory))).Returns(loggerFactoryMock.Object);
+ requestServicesMock.Setup(s => s.GetService(typeof(IUrlHelperFactory))).Returns(urlHelperFactoryMock.Object);
+ httpContext.RequestServices = requestServicesMock.Object;
+ _controller.ControllerContext = new ControllerContext { HttpContext = httpContext };
+ _controller.TempData = new TempDataDictionary(httpContext, new Mock<ITempDataProvider>().Object);
+ }
+
+ [TestMethod]
+ public void BlogController_IsThinSubclassOfBaseBlogController()
+ {
+ Assert.IsTrue(typeof(BlogController).IsSubclassOf(typeof(BaseBlogController)));
+ }
+
+ [TestMethod]
+ public void BlogController_HasRequiredHostAttributes()
+ {
+ var type = typeof(BlogController);
+ Assert.IsTrue(type.IsDefined(typeof(AreaAttribute), inherit: false), "[Area] missing");
+ Assert.IsTrue(type.IsDefined(typeof(AuthorizeStoreAttribute), inherit: false), "[AuthorizeStore] missing");
+ Assert.IsTrue(type.IsDefined(typeof(AuthorizeMenuAttribute), inherit: false), "[AuthorizeMenu] missing");
+ Assert.IsTrue(type.IsDefined(typeof(AutoValidateAntiforgeryTokenAttribute), inherit: false), "[AutoValidateAntiforgeryToken] missing");
+
+ var area = type.GetCustomAttribute<AreaAttribute>()!;
+ Assert.AreEqual("Store", area.RouteValue);
+ }
+
+ [TestMethod]
+ public async Task Preview_PostNotFound_RedirectsToList()
+ {
+ _blogServiceMock.Setup(b => b.GetBlogPostById("missing")).ReturnsAsync((BlogPost)null);
+
+ var result = await _controller.Preview("missing");
+
+ var redirect = result as RedirectToActionResult;
+ Assert.IsNotNull(redirect);
+ Assert.AreEqual("List", redirect.ActionName);
+ }
+
+ [TestMethod]
+ public async Task Preview_ScopeDeniesAccess_RedirectsToList()
+ {
+ var post = new BlogPost { Id = "p1" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(false);
+
+ var result = await _controller.Preview("p1");
+
+ var redirect = result as RedirectToActionResult;
+ Assert.IsNotNull(redirect);
+ Assert.AreEqual("List", redirect.ActionName);
+ }
+
+ [TestMethod]
+ public async Task Preview_ScopeGrantsAccess_ReturnsViewWithModel()
+ {
+ var post = new BlogPost { Id = "p1", Title = "Hello" };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("p1")).ReturnsAsync(post);
+ _postScopeMock.Setup(s => s.HasAccess(post)).ReturnsAsync(true);
+
+ var result = await _controller.Preview("p1");
+
+ var view = result as ViewResult;
+ Assert.IsNotNull(view);
+ }
+
+ // --- EditWarningCheck ----------------------------------------------------------------------
+ //
+ // Characterization tests for BlogController.EditWarningCheck, the one hand-ported piece of
+ // business logic in the Blog consolidation (ARCH-001 Phase 14). Exercised indirectly through
+ // the public Edit(GET) action, since EditWarningCheck itself is protected. Identical condition
+ // shape to BrandController's EditWarningCheck (Phase 13).
+
+ [TestClass]
+ public class EditWarningCheckTests
+ {
+ private const string PermissionsResourceKey = "Admin.Content.Blog.BlogPosts.Permissions";
+
+ private BlogController _controller;
+ private Mock<IBlogService> _blogServiceMock;
+ private Mock<ITranslationService> _translationServiceMock;
+ private Mock<IAdminDataScope<BlogPost>> _postScopeMock;
+
+ [TestInitialize]
+ public void Setup()
+ {
+ var mapperConfig = new MapperConfiguration(cfg =>
+ {
+ cfg.AddProfile<BlogPostProfile>();
+ cfg.AddProfile<BlogCategoryProfile>();
+ });
+ AutoMapperConfig.Init(mapperConfig);
+
+ _blogServiceMock = new Mock<IBlogService>();
+ _translationServiceMock = new Mock<ITranslationService>();
+ _translationServiceMock.Setup(t => t.GetResource(It.IsAny<string>())).Returns("resource");
+
+ _postScopeMock = new Mock<IAdminDataScope<BlogPost>>();
+ _postScopeMock.Setup(s => s.DefaultStoreId).Returns("store-1");
+ _postScopeMock.Setup(s => s.CanView(It.IsAny<BlogPost>())).ReturnsAsync(true);
+
+ var languageServiceMock = new Mock<ILanguageService>();
+ languageServiceMock.Setup(l => l.GetAllLanguages(true, It.IsAny<string>()))
+ .ReturnsAsync(new List<Grand.Domain.Localization.Language>());
+
+ _controller = new BlogController(
+ _blogServiceMock.Object,
+ new Mock<IBlogViewModelService>().Object,
+ languageServiceMock.Object,
+ _translationServiceMock.Object,
+ new Mock<IStoreService>().Object,
+ new Mock<IDateTimeService>().Object,
+ new Mock<IPictureViewModelService>().Object,
+ new SeoSettings(),
+ _postScopeMock.Object,
+ new Mock<IAdminDataScope<BlogCategory>>().Object);
+
+ var httpContext = new DefaultHttpContext();
+ var loggerFactoryMock = new Mock<ILoggerFactory>();
+ loggerFactoryMock.Setup(l => l.CreateLogger(It.IsAny<string>())).Returns(new Mock<ILogger>().Object);
+ var urlHelperFactoryMock = new Mock<IUrlHelperFactory>();
+ urlHelperFactoryMock.Setup(f => f.GetUrlHelper(It.IsAny<ActionContext>())).Returns(new Mock<IUrlHelper>().Object);
+ var requestServicesMock = new Mock<IServiceProvider>();
+ requestServicesMock.Setup(s => s.GetService(typeof(ILoggerFactory))).Returns(loggerFactoryMock.Object);
+ requestServicesMock.Setup(s => s.GetService(typeof(IUrlHelperFactory))).Returns(urlHelperFactoryMock.Object);
+ httpContext.RequestServices = requestServicesMock.Object;
+ _controller.ControllerContext = new ControllerContext { HttpContext = httpContext };
+ _controller.TempData = new TempDataDictionary(httpContext, new Mock<ITempDataProvider>().Object);
+ }
+
+ private bool WarningWasRaised()
+ {
+ return _controller.TempData["grand.notifications.Warning"] is List<string> warnings
+ && warnings.Contains("resource");
+ }
+
+ [TestMethod]
+ public async Task EditGet_NotLimitedToStores_RaisesPermissionsWarning()
+ {
+ var blogPost = new BlogPost { Id = "b1", LimitedToStores = false, Stores = [] };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("b1")).ReturnsAsync(blogPost);
+
+ await _controller.Edit("b1");
+
+ Assert.IsTrue(WarningWasRaised());
+ _translationServiceMock.Verify(t => t.GetResource(PermissionsResourceKey), Times.Once);
+ }
+
+ [TestMethod]
+ public async Task EditGet_LimitedToStores_ContainsDefaultStore_MultipleStores_RaisesPermissionsWarning()
+ {
+ var blogPost = new BlogPost { Id = "b1", LimitedToStores = true, Stores = ["store-1", "store-2"] };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("b1")).ReturnsAsync(blogPost);
+
+ await _controller.Edit("b1");
+
+ Assert.IsTrue(WarningWasRaised());
+ _translationServiceMock.Verify(t => t.GetResource(PermissionsResourceKey), Times.Once);
+ }
+
+ [TestMethod]
+ public async Task EditGet_LimitedToStores_ContainsDefaultStore_SingleStore_DoesNotRaiseWarning()
+ {
+ var blogPost = new BlogPost { Id = "b1", LimitedToStores = true, Stores = ["store-1"] };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("b1")).ReturnsAsync(blogPost);
+
+ await _controller.Edit("b1");
+
+ Assert.IsFalse(WarningWasRaised());
+ _translationServiceMock.Verify(t => t.GetResource(PermissionsResourceKey), Times.Never);
+ }
+
+ [TestMethod]
+ public async Task EditGet_LimitedToStores_DoesNotContainDefaultStore_DoesNotRaiseWarning()
+ {
+ var blogPost = new BlogPost { Id = "b1", LimitedToStores = true, Stores = ["store-2", "store-3"] };
+ _blogServiceMock.Setup(b => b.GetBlogPostById("b1")).ReturnsAsync(blogPost);
+
+ await _controller.Edit("b1");
+
+ Assert.IsFalse(WarningWasRaised());
+ _translationServiceMock.Verify(t => t.GetResource(PermissionsResourceKey), Times.Never);
+ }
+ }
+}
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/CategoryList.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/CategoryList.cshtml
deleted file mode 100644
index 25fb5fce8..000000000
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/CategoryList.cshtml
+++ /dev/null
@@ -1,85 +0,0 @@
-@inject AdminAreaSettings adminAreaSettings
-@{
- //page title
- ViewBag.Title = Loc["Admin.Content.Blog.BlogCategories"];
-}
-
-<div class="row">
- <div class="col-md-12">
- <div class="x_panel light form-fit">
- <div class="x_title">
- <div class="caption">
- <i class="fa fa-comment"></i>
- @Loc["Admin.Content.Blog.BlogCategories"]
- </div>
- <div class="actions btn-group btn-group-devided">
- <a href="@Url.Action("CategoryCreate", new { area = Constants.AreaAdmin })" class="btn green">
- <i class="fa fa-plus"></i><span class="d-none d-sm-inline"> @Loc["Admin.Common.AddNew"] </span>
- </a>
- </div>
- </div>
- <div class="x_content form">
- <div class="form-horizontal">
- <div class="form-body">
- <div class="x_content">
- <div id="blogcategory-grid"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-</div>
-
-<script>
- $(document).ready(function () {
- $("#blogcategory-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("CategoryList", "Blog", new { area = Constants.AreaAdmin }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors"
- },
- error: function(e) {
- display_kendoui_grid_error(e);
- // Cancel the changes
- this.cancelChanges();
- },
- pageSize: @(adminAreaSettings.DefaultGridPageSize),
- serverPaging: true,
- serverFiltering: true,
- serverSorting: true
- },
- pageable: {
- refresh: true,
- pageSizes: [@(adminAreaSettings.GridPageSizes)]
- },
- editable: {
- confirmation: false,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "Name",
- title: "@Loc["Admin.Content.Blog.BlogCategory.Fields.Name"]",
- width: 600,
- template: '<a class="k-link" href="CategoryEdit/#=Id#">#=kendo.htmlEncode(Name)#</a>',
- },
- {
- field: "DisplayOrder",
- headerAttributes: { style: "text-align:center" },
- attributes: { style: "text-align:center" },
- title: "@Loc["Admin.Content.Blog.BlogCategory.Fields.DisplayOrder"]",
- width: 100,
- }]
- });
- });
-</script>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Edit.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Edit.cshtml
deleted file mode 100644
index 101df9f65..000000000
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Edit.cshtml
+++ /dev/null
@@ -1,46 +0,0 @@
-@model BlogPostModel
-@{
- //page title
- ViewBag.Title = Loc["Admin.Content.Blog.BlogPosts.EditBlogPostDetails"];
-}
-
-<form asp-area="@Constants.AreaAdmin" asp-controller="Blog" asp-action="Edit" method="post" id="blog-edit">
-
- <div class="row">
- <div class="col-md-12">
- <div class="x_panel light form-fit">
- <div class="x_title">
- <div class="caption">
- <i class="fa fa-comment"></i>
- @Loc["Admin.Content.Blog.BlogPosts.EditBlogPostDetails"] - @Model.Title
- <small>
- <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Content.Blog.BlogPosts.BackToList"], "List")
- </small>
- </div>
- <div class="actions">
- <div class="btn-group btn-group-devided">
- <button type="button" onclick="window.open('@Url.RouteUrl("BlogPost", new { Model.SeName })','_blank');" class="btn purple">
- <i class="fa fa-eye"></i>
- @Loc["Admin.Common.Preview"]
- </button>
- <button class="btn btn-success" type="submit" name="save">
- <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]
- </button>
- <button class="btn btn-success" type="submit" name="save-continue">
- <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]
- </button>
- <span id="blogpost-delete" class="btn red">
- <i class="fa fa-trash-o"></i> @Loc["Admin.Common.Delete"]
- </span>
- </div>
- </div>
- </div>
- <vc:admin-widget widget-zone="blog_details_buttons" additional-data="Model"/>
- <div class="x_content form">
- <partial name="Partials/CreateOrUpdate" model="Model"/>
- </div>
- </div>
- </div>
- </div>
-</form>
-<admin-delete-confirmation button-id="blogpost-delete"/>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/List.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/List.cshtml
deleted file mode 100644
index 4c69ec6d8..000000000
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/List.cshtml
+++ /dev/null
@@ -1,101 +0,0 @@
-@inject AdminAreaSettings adminAreaSettings
-@{
- //page title
- ViewBag.Title = Loc["Admin.Content.Blog.BlogPosts"];
-}
-
-<div class="row">
- <div class="col-md-12">
- <div class="x_panel light form-fit">
- <div class="x_title">
- <div class="caption">
- <i class="fa fa-comment"></i>
- @Loc["Admin.Content.Blog.BlogPosts"]
- </div>
- <div class="actions btn-group btn-group-devided">
- <a href="@Url.Action("Create", new { area = Constants.AreaAdmin })" class="btn green">
- <i class="fa fa-plus"></i><span class="d-none d-sm-inline"> @Loc["Admin.Common.AddNew"] </span>
- </a>
- </div>
- </div>
- <div class="x_content form">
- <div class="form-horizontal">
- <div class="form-body">
- <div class="x_content">
- <div id="blogpost-grid"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-</div>
-
-<script>
- $(document).ready(function () {
- $("#blogpost-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("List", "Blog", new { area = Constants.AreaAdmin }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors"
- },
- error: function(e) {
- display_kendoui_grid_error(e);
- // Cancel the changes
- this.cancelChanges();
- },
- pageSize: @(adminAreaSettings.DefaultGridPageSize),
- serverPaging: true,
- serverFiltering: true,
- serverSorting: true
- },
- pageable: {
- refresh: true,
- pageSizes: [@(adminAreaSettings.GridPageSizes)]
- },
- editable: {
- confirmation: false,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "Title",
- title: "@Loc["Admin.Content.Blog.BlogPosts.Fields.Title"]",
- width: 400,
- template: '<a class="k-link" href="Edit/#=Id#">#=kendo.htmlEncode(Title)#</a>',
- }, {
- field: "Comments",
- title: "@Loc["Admin.Content.Blog.BlogPosts.Fields.Comments"]",
- width: 200,
- template: '<a class="k-link" href="Comments?filterByBlogPostId=#=Id#">@Loc["Admin.Content.Blog.BlogPosts.Fields.Comments"] - #=Comments# </a>'
- }, {
- field: "StartDate",
- title: "@Loc["Admin.Content.Blog.BlogPosts.Fields.StartDate"]",
- width: 150,
- type: "date",
- format: "{0:G}"
- }, {
- field: "EndDate",
- title: "@Loc["Admin.Content.Blog.BlogPosts.Fields.EndDate"]",
- width: 150,
- type: "date",
- format: "{0:G}"
- }, {
- field: "CreatedOn",
- title: "@Loc["Admin.Content.Blog.BlogPosts.Fields.CreatedOn"]",
- width: 200,
- type: "date",
- format: "{0:G}"
- }]
- });
- });
-</script>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdateCategory.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdateCategory.cshtml
deleted file mode 100644
index 2271f47aa..000000000
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdateCategory.cshtml
+++ /dev/null
@@ -1,23 +0,0 @@
-@model BlogCategoryModel
-
-<div asp-validation-summary="All"></div>
-<input asp-for="Id" type="hidden"/>
-<admin-tabstrip name="blog-category-edit">
- <items>
- <tabstrip-item text="@Loc["Admin.Content.Blog.BlogCategory.Info"]" tab-index="0">
- <content>
- <div>
- <partial name="Partials/CreateOrUpdateCategory.TabInfo" model="Model"/>
- </div>
- </content>
- </tabstrip-item>
- <tabstrip-item text="@Loc["Admin.Content.Blog.BlogCategory.Posts"]" tab-index="1">
- <content>
- <div>
- <partial name="Partials/CreateOrUpdateCategory.Posts" model="Model"/>
- </div>
- </content>
- </tabstrip-item>
- <vc:admin-widget widget-zone="blog_category_details_tabs" additional-data="Model"/>
- </items>
-</admin-tabstrip>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryButtons.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryButtons.cshtml
new file mode 100644
index 000000000..cfc6af5f2
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryButtons.cshtml
@@ -0,0 +1,2 @@
+@model dynamic
+<vc:admin-widget widget-zone="blog_category_buttons" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryButtonsCreate.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryButtonsCreate.cshtml
new file mode 100644
index 000000000..b4f3c6de3
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryButtonsCreate.cshtml
@@ -0,0 +1,2 @@
+@model dynamic
+<vc:admin-widget widget-zone="blog_category_buttons" additional-data="null"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryInfo.Bottom.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryInfo.Bottom.cshtml
new file mode 100644
index 000000000..aaaf9f63a
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryInfo.Bottom.cshtml
@@ -0,0 +1,2 @@
+@model BlogCategoryModel
+<vc:admin-widget widget-zone="blog_category_info_bottom" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryInfo.Top.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryInfo.Top.cshtml
new file mode 100644
index 000000000..34ca3b52f
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryInfo.Top.cshtml
@@ -0,0 +1,2 @@
+@model BlogCategoryModel
+<vc:admin-widget widget-zone="blog_category_info_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryTabs.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryTabs.cshtml
new file mode 100644
index 000000000..ea122eb5b
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.CategoryTabs.cshtml
@@ -0,0 +1,2 @@
+@model BlogCategoryModel
+<vc:admin-widget widget-zone="blog_category_details_tabs" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Comments.Bottom.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Comments.Bottom.cshtml
new file mode 100644
index 000000000..dde826381
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Comments.Bottom.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:admin-widget widget-zone="blog_details_comments_bottom" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Comments.Top.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Comments.Top.cshtml
new file mode 100644
index 000000000..39d6a6acf
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Comments.Top.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:admin-widget widget-zone="blog_details_comments_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.DetailsButtons.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.DetailsButtons.cshtml
new file mode 100644
index 000000000..2e865a98a
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.DetailsButtons.cshtml
@@ -0,0 +1,2 @@
+@model dynamic
+<vc:admin-widget widget-zone="blog_details_buttons" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.DetailsButtonsCreate.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.DetailsButtonsCreate.cshtml
new file mode 100644
index 000000000..f2339fb4a
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.DetailsButtonsCreate.cshtml
@@ -0,0 +1,2 @@
+@model dynamic
+<vc:admin-widget widget-zone="blog_details_buttons" additional-data="null"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Info.Bottom.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Info.Bottom.cshtml
new file mode 100644
index 000000000..b7b7ce7ab
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Info.Bottom.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:admin-widget widget-zone="blog_details_info_bottom" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Info.Top.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Info.Top.cshtml
new file mode 100644
index 000000000..742c62084
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Info.Top.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:admin-widget widget-zone="blog_details_info_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Products.Bottom.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Products.Bottom.cshtml
new file mode 100644
index 000000000..4d2db15fb
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Products.Bottom.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:admin-widget widget-zone="blog_details_product_bottom" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Products.Top.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Products.Top.cshtml
new file mode 100644
index 000000000..0c3e01a83
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Products.Top.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:admin-widget widget-zone="blog_details_product_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.SEO.Bottom.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.SEO.Bottom.cshtml
new file mode 100644
index 000000000..446a64746
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.SEO.Bottom.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:admin-widget widget-zone="blog_details_seo_bottom" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.SEO.Top.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.SEO.Top.cshtml
new file mode 100644
index 000000000..a5ab20752
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.SEO.Top.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:admin-widget widget-zone="blog_details_seo_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Tabs.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Tabs.cshtml
new file mode 100644
index 000000000..25fa8c68d
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/WidgetZone.Tabs.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:admin-widget widget-zone="blog_details_tabs" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Controllers/BlogController.cs b/src/Web/Grand.Web.Admin/Controllers/BlogController.cs
index 67792b9bf..de691d45e 100644
--- a/src/Web/Grand.Web.Admin/Controllers/BlogController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/BlogController.cs
@@ -1,605 +1,36 @@
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Stores;
-using Grand.Domain.Permissions;
+using Grand.Domain.Blogs;
using Grand.Domain.Seo;
-using Grand.Web.AdminShared.Extensions.Mapping;
+using Grand.Web.Admin.Extensions;
+using Grand.Web.AdminShared.Controllers;
using Grand.Web.AdminShared.Interfaces;
-using Grand.Web.AdminShared.Models.Blogs;
-using Grand.Web.AdminShared.Models.Common;
-using Grand.Web.Common.DataSource;
using Grand.Web.Common.Filters;
-using Grand.Web.Common.Security.Authorization;
+using Grand.Web.Common.Localization;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Admin.Controllers;
-[PermissionAuthorize(PermissionSystemName.Blog)]
-public class BlogController : BaseAdminController
-{
- #region Constructors
-
- public BlogController(
- IBlogService blogService,
- IBlogViewModelService blogViewModelService,
- ILanguageService languageService,
- ITranslationService translationService,
- IStoreService storeService,
- IDateTimeService dateTimeService,
- IPictureViewModelService pictureViewModelService,
- SeoSettings seoSettings)
- {
- _blogService = blogService;
- _blogViewModelService = blogViewModelService;
- _languageService = languageService;
- _translationService = translationService;
- _storeService = storeService;
- _dateTimeService = dateTimeService;
- _pictureViewModelService = pictureViewModelService;
- _seoSettings = seoSettings;
- }
-
- #endregion
-
- #region Fields
-
- private readonly IBlogService _blogService;
- private readonly IBlogViewModelService _blogViewModelService;
- private readonly ILanguageService _languageService;
- private readonly ITranslationService _translationService;
- private readonly IStoreService _storeService;
- private readonly IDateTimeService _dateTimeService;
- private readonly IPictureViewModelService _pictureViewModelService;
- private readonly SeoSettings _seoSettings;
-
- #endregion
-
- #region Blog posts
-
- public IActionResult Index()
- {
- return RedirectToAction("List");
- }
-
- public IActionResult List()
- {
- return View();
- }
-
- [PermissionAuthorizeAction(PermissionActionName.List)]
- [HttpPost]
- public async Task<IActionResult> List(DataSourceRequest command)
- {
- var blogPosts = await _blogViewModelService.PrepareBlogPostsModel(command.Page, command.PageSize);
- var gridModel = new DataSourceResult {
- Data = blogPosts.blogPosts,
- Total = blogPosts.totalCount
- };
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Create)]
- public async Task<IActionResult> Create()
- {
- ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);
- var model = new BlogPostModel {
- //default values
- AllowComments = true,
- CreateDate = DateTime.UtcNow
- };
- //locales
- await AddLocales(_languageService, model.Locales);
-
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
- public async Task<IActionResult> Create(BlogPostModel model, bool continueEditing)
- {
- if (ModelState.IsValid)
- {
- var blogPost = await _blogViewModelService.InsertBlogPostModel(model);
- Success(_translationService.GetResource("Admin.Content.Blog.BlogPosts.Added"));
- return continueEditing ? RedirectToAction("Edit", new { id = blogPost.Id }) : RedirectToAction("List");
- }
-
- //If we got this far, something failed, redisplay form
- ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);
-
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Preview)]
- public async Task<IActionResult> Edit(string id)
- {
- var blogPost = await _blogService.GetBlogPostById(id);
- if (blogPost == null)
- //No blog post found with the specified id
- return RedirectToAction("List");
-
- ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);
- var model = blogPost.ToModel(_dateTimeService);
- //locales
- await AddLocales(_languageService, model.Locales, (locale, languageId) =>
- {
- locale.Title = blogPost.GetTranslation(x => x.Title, languageId, false);
- locale.Body = blogPost.GetTranslation(x => x.Body, languageId, false);
- locale.BodyOverview = blogPost.GetTranslation(x => x.BodyOverview, languageId, false);
- locale.MetaKeywords = blogPost.GetTranslation(x => x.MetaKeywords, languageId, false);
- locale.MetaDescription = blogPost.GetTranslation(x => x.MetaDescription, languageId, false);
- locale.MetaTitle = blogPost.GetTranslation(x => x.MetaTitle, languageId, false);
- locale.SeName = blogPost.GetSeName(languageId, false);
- });
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
- public async Task<IActionResult> Edit(BlogPostModel model, bool continueEditing)
- {
- var blogPost = await _blogService.GetBlogPostById(model.Id);
- if (blogPost == null)
- //No blog post found with the specified id
- return RedirectToAction("List");
-
- if (ModelState.IsValid)
- {
- blogPost = await _blogViewModelService.UpdateBlogPostModel(model, blogPost);
-
- Success(_translationService.GetResource("Admin.Content.Blog.BlogPosts.Updated"));
- if (continueEditing)
- {
- //selected tab
- await SaveSelectedTabIndex();
-
- return RedirectToAction("Edit", new { id = blogPost.Id });
- }
-
- return RedirectToAction("List");
- }
-
- //If we got this far, something failed, redisplay form
- ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);
-
- //locales
- await AddLocales(_languageService, model.Locales, (locale, languageId) =>
- {
- locale.Title = blogPost.GetTranslation(x => x.Title, languageId, false);
- locale.Body = blogPost.GetTranslation(x => x.Body, languageId, false);
- locale.BodyOverview = blogPost.GetTranslation(x => x.BodyOverview, languageId, false);
- locale.MetaKeywords = blogPost.GetTranslation(x => x.MetaKeywords, languageId, false);
- locale.MetaDescription = blogPost.GetTranslation(x => x.MetaDescription, languageId, false);
- locale.MetaTitle = blogPost.GetTranslation(x => x.MetaTitle, languageId, false);
- locale.SeName = blogPost.GetSeName(languageId, false);
- });
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- [HttpPost]
- public async Task<IActionResult> Delete(string id)
- {
- var blogPost = await _blogService.GetBlogPostById(id);
- if (blogPost == null)
- //No blog post found with the specified id
- return RedirectToAction("List");
-
- if (ModelState.IsValid)
- {
- await _blogService.DeleteBlogPost(blogPost);
-
- Success(_translationService.GetResource("Admin.Content.Blog.BlogPosts.Deleted"));
- return RedirectToAction("List");
- }
-
- Error(ModelState);
- return RedirectToAction("Edit", new { id });
- }
-
- #endregion
-
- #region Picture
-
- [PermissionAuthorizeAction(PermissionActionName.Preview)]
- public async Task<IActionResult> PicturePopup(string blogpostId)
- {
- var blogpost = await _blogService.GetBlogPostById(blogpostId);
- if (blogpost == null)
- return Content("Blog post not exist");
-
- if (string.IsNullOrEmpty(blogpost.PictureId))
- return Content("Picture not exist");
-
- return View("Partials/PicturePopup",
- await _pictureViewModelService.PreparePictureModel(blogpost.PictureId, blogpost.Id));
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- public async Task<IActionResult> PicturePopup(PictureModel model)
- {
- if (ModelState.IsValid)
- {
- var blogpost = await _blogService.GetBlogPostById(model.ObjectId);
- if (blogpost == null)
- throw new ArgumentException("No blog post found with the specified id");
-
- if (string.IsNullOrEmpty(blogpost.PictureId))
- throw new ArgumentException("No picture found with the specified id");
-
- if (blogpost.PictureId != model.Id)
- throw new ArgumentException("Picture ident doesn't fit with blog post");
-
- await _pictureViewModelService.UpdatePicture(model);
-
- return Content("");
- }
-
- Error(ModelState);
-
- return View("Partials/PicturePopup", model);
- }
-
- #endregion
-
- #region Categories
-
- public IActionResult CategoryList()
- {
- return View();
- }
-
- [PermissionAuthorizeAction(PermissionActionName.List)]
- [HttpPost]
- public async Task<IActionResult> CategoryList(DataSourceRequest command)
- {
- var categories = await _blogService.GetAllBlogCategories("");
- var gridModel = new DataSourceResult {
- Data = categories,
- Total = categories.Count
- };
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Create)]
- public async Task<IActionResult> CategoryCreate()
- {
- ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);
- var model = new BlogCategoryModel();
- //locales
- await AddLocales(_languageService, model.Locales);
-
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
- public async Task<IActionResult> CategoryCreate(BlogCategoryModel model, bool continueEditing)
- {
- if (ModelState.IsValid)
- {
- var blogCategory = model.ToEntity();
- blogCategory.SeName = SeoExtensions.GetSeName(
- string.IsNullOrEmpty(blogCategory.SeName) ? blogCategory.Name : blogCategory.SeName,
- _seoSettings.ConvertNonWesternChars, _seoSettings.AllowUnicodeCharsInUrls,
- _seoSettings.SeoCharConversion);
-
- await _blogService.InsertBlogCategory(blogCategory);
- Success(_translationService.GetResource("Admin.Content.Blog.BlogCategory.Added"));
- return continueEditing
- ? RedirectToAction("CategoryEdit", new { id = blogCategory.Id })
- : RedirectToAction("CategoryList");
- }
-
- //If we got this far, something failed, redisplay form
- ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);
- //locales
- await AddLocales(_languageService, model.Locales);
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Preview)]
- public async Task<IActionResult> CategoryEdit(string id)
- {
- var blogCategory = await _blogService.GetBlogCategoryById(id);
- if (blogCategory == null)
- //No blog post found with the specified id
- return RedirectToAction("CategoryList");
-
- ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);
- var model = blogCategory.ToModel();
- //locales
- await AddLocales(_languageService, model.Locales, (locale, languageId) =>
- {
- locale.Name = blogCategory.GetTranslation(x => x.Name, languageId, false);
- });
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
- public async Task<IActionResult> CategoryEdit(BlogCategoryModel model, bool continueEditing)
- {
- var blogCategory = await _blogService.GetBlogCategoryById(model.Id);
- if (blogCategory == null)
- //No blog post found with the specified id
- return RedirectToAction("CategoryList");
-
- if (ModelState.IsValid)
- {
- blogCategory = model.ToEntity(blogCategory);
- blogCategory.SeName = SeoExtensions.GetSeName(
- string.IsNullOrEmpty(blogCategory.SeName) ? blogCategory.Name : blogCategory.SeName,
- _seoSettings.ConvertNonWesternChars, _seoSettings.AllowUnicodeCharsInUrls,
- _seoSettings.SeoCharConversion);
- await _blogService.UpdateBlogCategory(blogCategory);
- Success(_translationService.GetResource("Admin.Content.Blog.BlogCategory.Updated"));
- if (continueEditing)
- {
- //selected tab
- await SaveSelectedTabIndex();
-
- return RedirectToAction("CategoryEdit", new { id = blogCategory.Id });
- }
-
- return RedirectToAction("CategoryList");
- }
-
- //If we got this far, something failed, redisplay form
- ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);
-
- //locales
- await AddLocales(_languageService, model.Locales, (locale, languageId) =>
- {
- locale.Name = blogCategory.GetTranslation(x => x.Name, languageId, false);
- });
-
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- [HttpPost]
- public async Task<IActionResult> CategoryDelete(string id)
- {
- var blogcategory = await _blogService.GetBlogCategoryById(id);
- if (blogcategory == null)
- //No blog post found with the specified id
- return RedirectToAction("CategoryList");
-
- if (ModelState.IsValid)
- {
- await _blogService.DeleteBlogCategory(blogcategory);
-
- Success(_translationService.GetResource("Admin.Content.Blog.BlogCategory.Deleted"));
- return RedirectToAction("CategoryList");
- }
-
- Error(ModelState);
- return RedirectToAction("CategoryEdit", new { id = blogcategory.Id });
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Preview)]
- [HttpPost]
- public async Task<IActionResult> CategoryPostList(string categoryId)
- {
- var blogCategory = await _blogService.GetBlogCategoryById(categoryId);
- if (blogCategory == null)
- return ErrorForKendoGridJson("blogCategory no exists");
-
- var blogposts = new List<BlogCategoryPost>();
- foreach (var item in blogCategory.BlogPosts)
- {
- var post = new BlogCategoryPost {
- Id = item.Id,
- BlogPostId = item.BlogPostId
- };
- var _post = await _blogService.GetBlogPostById(item.BlogPostId);
- if (_post != null)
- post.Name = _post.Title;
-
- blogposts.Add(post);
- }
-
- var gridModel = new DataSourceResult {
- Data = blogposts,
- Total = blogCategory.BlogPosts.Count
- };
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- public async Task<IActionResult> CategoryPostDelete(string categoryId, string id)
- {
- var blogCategory = await _blogService.GetBlogCategoryById(categoryId);
- if (blogCategory == null)
- return ErrorForKendoGridJson("blogCategory no exists");
-
- if (ModelState.IsValid)
- {
- var post = blogCategory.BlogPosts.FirstOrDefault(x => x.Id == id);
- if (post != null)
- {
- blogCategory.BlogPosts.Remove(post);
- await _blogService.UpdateBlogCategory(blogCategory);
- }
-
- return new JsonResult("");
- }
-
- return ErrorForKendoGridJson(ModelState);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- public async Task<IActionResult> BlogPostAddPopup(string categoryId)
- {
- var model = new AddBlogPostCategoryModel();
- //stores
- model.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });
- foreach (var s in await _storeService.GetAllStores())
- model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });
- model.CategoryId = categoryId;
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- public async Task<IActionResult> BlogPostAddPopupList(DataSourceRequest command, AddBlogPostCategoryModel model)
- {
- var gridModel = new DataSourceResult();
-
- var posts = await _blogService.GetAllBlogPosts(model.SearchStoreId, blogPostName: model.SearchBlogTitle,
- pageIndex: command.Page - 1, pageSize: command.PageSize);
- gridModel.Data = posts.Select(x => new { x.Id, Name = x.Title });
- gridModel.Total = posts.TotalCount;
-
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- public async Task<IActionResult> BlogPostAddPopup(AddBlogPostCategoryModel model)
- {
- if (model.SelectedBlogPostIds != null)
- {
- var blogCategory = await _blogService.GetBlogCategoryById(model.CategoryId);
- if (blogCategory != null)
- foreach (var id in model.SelectedBlogPostIds)
- {
- var post = await _blogService.GetBlogPostById(id);
- if (post != null)
- if (!blogCategory.BlogPosts.Any(x => x.BlogPostId == id))
- {
- blogCategory.BlogPosts.Add(new Domain.Blogs.BlogCategoryPost { BlogPostId = id });
- await _blogService.UpdateBlogCategory(blogCategory);
- }
- }
- }
-
- return Content("");
- }
-
- #endregion
-
- #region Comments
-
- public IActionResult Comments(string filterByBlogPostId)
- {
- ViewBag.FilterByBlogPostId = filterByBlogPostId;
- return View();
- }
-
- [PermissionAuthorizeAction(PermissionActionName.List)]
- [HttpPost]
- public async Task<IActionResult> Comments(string filterByBlogPostId, DataSourceRequest command)
- {
- var model = await _blogViewModelService.PrepareBlogPostCommentsModel(filterByBlogPostId, command.Page,
- command.PageSize);
- var gridModel = new DataSourceResult {
- Data = model.blogComments,
- Total = model.totalCount
- };
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- public async Task<IActionResult> CommentDelete(string id)
- {
- var comment = await _blogService.GetBlogCommentById(id);
- if (comment == null)
- throw new ArgumentException("No comment found with the specified id");
-
- var blogPost = await _blogService.GetBlogPostById(comment.BlogPostId);
-
- if (ModelState.IsValid)
- {
- await _blogService.DeleteBlogComment(comment);
- //update totals
- var comments = await _blogService.GetBlogCommentsByBlogPostId(blogPost.Id);
- blogPost.CommentCount = comments.Count;
- await _blogService.UpdateBlogPost(blogPost);
- return new JsonResult("");
- }
-
- return ErrorForKendoGridJson(ModelState);
- }
-
- #endregion
-
- #region Products
-
- [PermissionAuthorizeAction(PermissionActionName.List)]
- [HttpPost]
- public async Task<IActionResult> Products(string blogPostId, DataSourceRequest command)
- {
- var model = await _blogViewModelService.PrepareBlogProductsModel(blogPostId, command.Page, command.PageSize);
- var gridModel = new DataSourceResult {
- Data = model.blogProducts,
- Total = model.totalCount
- };
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- public async Task<IActionResult> ProductAddPopup(string blogPostId)
- {
- var model = await _blogViewModelService.PrepareBlogModelAddProductModel(blogPostId);
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- public async Task<IActionResult> ProductAddPopupList(DataSourceRequest command,
- BlogProductModel.AddProductModel model)
- {
- var products = await _blogViewModelService.PrepareProductModel(model, command.Page, command.PageSize);
-
- var gridModel = new DataSourceResult {
- Data = products.products.ToList(),
- Total = products.totalCount
- };
-
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- public async Task<IActionResult> ProductAddPopup(string blogPostId, BlogProductModel.AddProductModel model)
- {
- if (model.SelectedProductIds != null) await _blogViewModelService.InsertProductModel(blogPostId, model);
- return Content("");
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- public async Task<IActionResult> UpdateProduct(BlogProductModel model)
- {
- if (ModelState.IsValid)
- {
- await _blogViewModelService.UpdateProductModel(model);
- return new JsonResult("");
- }
-
- return ErrorForKendoGridJson(ModelState);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- public async Task<IActionResult> DeleteProduct(string id)
- {
- if (ModelState.IsValid)
- {
- await _blogViewModelService.DeleteProductModel(id);
- return new JsonResult("");
- }
-
- return ErrorForKendoGridJson(ModelState);
- }
-
- #endregion
-}
\ No newline at end of file
+// Reduced to a thin subclass of BaseBlogController (ARCH-001 Blog consolidation). All regions of
+// behavior live in the shared base; this class only supplies Admin's DI wiring plus the attributes
+// that used to arrive transitively via BaseAdminController - BaseBlogController can't inherit any
+// single host's base controller. Same pattern as CategoryController (see that file).
+[AuthorizeAdmin]
+[AutoValidateAntiforgeryToken]
+[Area(Constants.AreaAdmin)]
+[AuthorizeMenu]
+public class BlogController(
+ IBlogService blogService,
+ IBlogViewModelService blogViewModelService,
+ ILanguageService languageService,
+ ITranslationService translationService,
+ IStoreService storeService,
+ IDateTimeService dateTimeService,
+ IPictureViewModelService pictureViewModelService,
+ SeoSettings seoSettings,
+ IAdminDataScope<BlogPost> postScope,
+ IAdminDataScope<BlogCategory> categoryScope)
+ : BaseBlogController(blogService, blogViewModelService, languageService, translationService,
+ storeService, dateTimeService, pictureViewModelService, seoSettings, postScope, categoryScope);
diff --git a/src/Web/Grand.Web.AdminShared/Controllers/BaseBlogController.cs b/src/Web/Grand.Web.AdminShared/Controllers/BaseBlogController.cs
new file mode 100644
index 000000000..0737726e9
--- /dev/null
+++ b/src/Web/Grand.Web.AdminShared/Controllers/BaseBlogController.cs
@@ -0,0 +1,578 @@
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
+using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Business.Core.Interfaces.Common.Stores;
+using Grand.Domain.Blogs;
+using Grand.Domain.Permissions;
+using Grand.Domain.Seo;
+using Grand.Web.AdminShared.Extensions.Mapping;
+using Grand.Web.AdminShared.Interfaces;
+using Grand.Web.AdminShared.Models.Blogs;
+using Grand.Web.AdminShared.Models.Common;
+using Grand.Web.Common.Controllers;
+using Grand.Web.Common.DataSource;
+using Grand.Web.Common.Filters;
+using Grand.Web.Common.Security.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Rendering;
+
+namespace Grand.Web.AdminShared.Controllers;
+
+// [AutoValidateAntiforgeryToken] restated on each concrete host subclass too (Task 8) - ASP.NET Core
+// resolves filters from the concrete controller's full type hierarchy at runtime, so every real
+// endpoint is already protected. Added here as well, mirroring BaseProductController/
+// BaseCategoryController.
+[PermissionAuthorize(PermissionSystemName.Blog)]
+[AutoValidateAntiforgeryToken]
+public abstract class BaseBlogController(
+ IBlogService blogService,
+ IBlogViewModelService blogViewModelService,
+ ILanguageService languageService,
+ ITranslationService translationService,
+ IStoreService storeService,
+ IDateTimeService dateTimeService,
+ IPictureViewModelService pictureViewModelService,
+ SeoSettings seoSettings,
+ IAdminDataScope<BlogPost> postScope,
+ IAdminDataScope<BlogCategory> categoryScope)
+ : BaseController
+{
+ protected const string NoAccessToBlogPostMessage = "You don't have access to this blog post";
+ protected const string NoAccessToBlogCategoryMessage = "You don't have access to this blog category";
+ protected const string CategoryListAction = "CategoryList";
+
+ /// <summary>Hook for host-specific UI-copy warnings on BlogPost Edit(GET) that aren't access-scope
+ /// decisions. Overridden by the Store subclass (Task 8); no-op everywhere else. Mirrors
+ /// BaseCategoryController.EditWarningCheck, and re-derives the identical condition Store's
+ /// original Category Edit(GET) already used.</summary>
+ protected virtual void EditWarningCheck(BlogPost blogPost) { }
+
+ // Exposed for host subclasses: primary-constructor parameters are not visible to derived classes
+ // by name in C#.
+ protected ITranslationService TranslationService => translationService;
+ protected IAdminDataScope<BlogPost> PostScope => postScope;
+ protected IAdminDataScope<BlogCategory> CategoryScope => categoryScope;
+
+ #region Blog posts
+
+ public IActionResult Index() => RedirectToAction("List");
+
+ public IActionResult List() => View();
+
+ [PermissionAuthorizeAction(PermissionActionName.List)]
+ [HttpPost]
+ public async Task<IActionResult> List(DataSourceRequest command)
+ {
+ // PrepareBlogPostsModel already reads StaffStoreId from ambient IContextAccessor and passes
+ // it into IBlogService.GetAllBlogPosts - Admin's empty StaffStoreId means unscoped, Store's
+ // means scoped, with zero controller involvement. Confirmed in the design spec §4 - no
+ // SearchStoreId forcing needed here, unlike every other entity in this initiative.
+ var blogPosts = await blogViewModelService.PrepareBlogPostsModel(command.Page, command.PageSize);
+ var gridModel = new DataSourceResult {
+ Data = blogPosts.blogPosts,
+ Total = blogPosts.totalCount
+ };
+ return Json(gridModel);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Create)]
+ public async Task<IActionResult> Create()
+ {
+ ViewBag.AllLanguages = await languageService.GetAllLanguages(true);
+ var model = new BlogPostModel {
+ AllowComments = true,
+ CreateDate = DateTime.UtcNow
+ };
+ await AddLocales(languageService, model.Locales);
+ return View(model);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ [HttpPost]
+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
+ public async Task<IActionResult> Create(BlogPostModel model, bool continueEditing)
+ {
+ if (ModelState.IsValid)
+ {
+ if (postScope.DefaultStoreId is not null) model.Stores = [postScope.DefaultStoreId];
+ var blogPost = await blogViewModelService.InsertBlogPostModel(model);
+ Success(translationService.GetResource("Admin.Content.Blog.BlogPosts.Added"));
+ return continueEditing ? RedirectToAction("Edit", new { id = blogPost.Id }) : RedirectToAction("List");
+ }
+
+ ViewBag.AllLanguages = await languageService.GetAllLanguages(true);
+ return View(model);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Preview)]
+ public async Task<IActionResult> Edit(string id)
+ {
+ var blogPost = await blogService.GetBlogPostById(id);
+ if (blogPost == null) return RedirectToAction("List");
+
+ // Warning (loose UI copy) vs deny (CanView, strict) - same split as Category's Edit(GET).
+ // Admin: no-op EditWarningCheck, CanView always true -> unaffected.
+ EditWarningCheck(blogPost);
+ if (!await postScope.CanView(blogPost)) return RedirectToAction("List");
+
+ ViewBag.AllLanguages = await languageService.GetAllLanguages(true);
+ var model = blogPost.ToModel(dateTimeService);
+ await AddLocales(languageService, model.Locales, (locale, languageId) =>
+ {
+ locale.Title = blogPost.GetTranslation(x => x.Title, languageId, false);
+ locale.Body = blogPost.GetTranslation(x => x.Body, languageId, false);
+ locale.BodyOverview = blogPost.GetTranslation(x => x.BodyOverview, languageId, false);
+ locale.MetaKeywords = blogPost.GetTranslation(x => x.MetaKeywords, languageId, false);
+ locale.MetaDescription = blogPost.GetTranslation(x => x.MetaDescription, languageId, false);
+ locale.MetaTitle = blogPost.GetTranslation(x => x.MetaTitle, languageId, false);
+ locale.SeName = blogPost.GetSeName(languageId, false);
+ });
+ return View(model);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ [HttpPost]
+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
+ public async Task<IActionResult> Edit(BlogPostModel model, bool continueEditing)
+ {
+ var blogPost = await blogService.GetBlogPostById(model.Id);
+ if (blogPost == null) return RedirectToAction("List");
+ if (!await postScope.HasAccess(blogPost)) return RedirectToAction("Edit", new { id = blogPost.Id });
+
+ if (ModelState.IsValid)
+ {
+ if (postScope.DefaultStoreId is not null) model.Stores = [postScope.DefaultStoreId];
+ blogPost = await blogViewModelService.UpdateBlogPostModel(model, blogPost);
+ Success(translationService.GetResource("Admin.Content.Blog.BlogPosts.Updated"));
+ if (continueEditing)
+ {
+ await SaveSelectedTabIndex();
+ return RedirectToAction("Edit", new { id = blogPost.Id });
+ }
+ return RedirectToAction("List");
+ }
+
+ ViewBag.AllLanguages = await languageService.GetAllLanguages(true);
+ await AddLocales(languageService, model.Locales, (locale, languageId) =>
+ {
+ locale.Title = blogPost.GetTranslation(x => x.Title, languageId, false);
+ locale.Body = blogPost.GetTranslation(x => x.Body, languageId, false);
+ locale.BodyOverview = blogPost.GetTranslation(x => x.BodyOverview, languageId, false);
+ locale.MetaKeywords = blogPost.GetTranslation(x => x.MetaKeywords, languageId, false);
+ locale.MetaDescription = blogPost.GetTranslation(x => x.MetaDescription, languageId, false);
+ locale.MetaTitle = blogPost.GetTranslation(x => x.MetaTitle, languageId, false);
+ locale.SeName = blogPost.GetSeName(languageId, false);
+ });
+ return View(model);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Delete)]
+ [HttpPost]
+ public async Task<IActionResult> Delete(string id)
+ {
+ var blogPost = await blogService.GetBlogPostById(id);
+ if (blogPost == null) return RedirectToAction("List");
+ if (!await postScope.HasAccess(blogPost)) return RedirectToAction("Edit", new { id });
+
+ if (ModelState.IsValid)
+ {
+ await blogService.DeleteBlogPost(blogPost);
+ Success(translationService.GetResource("Admin.Content.Blog.BlogPosts.Deleted"));
+ return RedirectToAction("List");
+ }
+
+ Error(ModelState);
+ return RedirectToAction("Edit", new { id });
+ }
+
+ #endregion
+
+ #region Picture
+
+ [PermissionAuthorizeAction(PermissionActionName.Preview)]
+ public async Task<IActionResult> PicturePopup(string blogpostId)
+ {
+ var blogpost = await blogService.GetBlogPostById(blogpostId);
+ if (blogpost == null) return Content("Blog post not exist");
+ if (!await postScope.HasAccess(blogpost)) return Content(NoAccessToBlogPostMessage);
+ if (string.IsNullOrEmpty(blogpost.PictureId)) return Content("Picture not exist");
+
+ return View("Partials/PicturePopup",
+ await pictureViewModelService.PreparePictureModel(blogpost.PictureId, blogpost.Id));
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ [HttpPost]
+ public async Task<IActionResult> PicturePopup(PictureModel model)
+ {
+ if (ModelState.IsValid)
+ {
+ var blogpost = await blogService.GetBlogPostById(model.ObjectId);
+ if (blogpost == null) throw new ArgumentException("No blog post found with the specified id");
+ if (!await postScope.HasAccess(blogpost)) return Content(NoAccessToBlogPostMessage);
+ if (string.IsNullOrEmpty(blogpost.PictureId)) throw new ArgumentException("No picture found with the specified id");
+ if (blogpost.PictureId != model.Id) throw new ArgumentException("Picture ident doesn't fit with blog post");
+
+ await pictureViewModelService.UpdatePicture(model);
+ return Content("");
+ }
+
+ Error(ModelState);
+ return View("Partials/PicturePopup", model);
+ }
+
+ #endregion
+
+ #region Categories
+
+ public IActionResult CategoryList() => View();
+
+ [PermissionAuthorizeAction(PermissionActionName.List)]
+ [HttpPost]
+ public async Task<IActionResult> CategoryList(DataSourceRequest command)
+ {
+ var categories = await blogService.GetAllBlogCategories(categoryScope.DefaultStoreId ?? "");
+ var gridModel = new DataSourceResult {
+ Data = categories,
+ Total = categories.Count
+ };
+ return Json(gridModel);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Create)]
+ public async Task<IActionResult> CategoryCreate()
+ {
+ ViewBag.AllLanguages = await languageService.GetAllLanguages(true);
+ var model = new BlogCategoryModel();
+ await AddLocales(languageService, model.Locales);
+ return View(model);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ [HttpPost]
+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
+ public async Task<IActionResult> CategoryCreate(BlogCategoryModel model, bool continueEditing)
+ {
+ if (ModelState.IsValid)
+ {
+ if (categoryScope.DefaultStoreId is not null) model.Stores = [categoryScope.DefaultStoreId];
+ var blogCategory = model.ToEntity();
+ blogCategory.SeName = SeoExtensions.GetSeName(
+ string.IsNullOrEmpty(blogCategory.SeName) ? blogCategory.Name : blogCategory.SeName,
+ seoSettings.ConvertNonWesternChars, seoSettings.AllowUnicodeCharsInUrls, seoSettings.SeoCharConversion);
+
+ await blogService.InsertBlogCategory(blogCategory);
+ Success(translationService.GetResource("Admin.Content.Blog.BlogCategory.Added"));
+ return continueEditing
+ ? RedirectToAction("CategoryEdit", new { id = blogCategory.Id })
+ : RedirectToAction(CategoryListAction);
+ }
+
+ ViewBag.AllLanguages = await languageService.GetAllLanguages(true);
+ await AddLocales(languageService, model.Locales);
+ return View(model);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Preview)]
+ public async Task<IActionResult> CategoryEdit(string id)
+ {
+ var blogCategory = await blogService.GetBlogCategoryById(id);
+ if (blogCategory == null) return RedirectToAction(CategoryListAction);
+ if (!await categoryScope.HasAccess(blogCategory)) return RedirectToAction(CategoryListAction);
+
+ ViewBag.AllLanguages = await languageService.GetAllLanguages(true);
+ var model = blogCategory.ToModel();
+ await AddLocales(languageService, model.Locales, (locale, languageId) =>
+ {
+ locale.Name = blogCategory.GetTranslation(x => x.Name, languageId, false);
+ });
+ return View(model);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ [HttpPost]
+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
+ public async Task<IActionResult> CategoryEdit(BlogCategoryModel model, bool continueEditing)
+ {
+ var blogCategory = await blogService.GetBlogCategoryById(model.Id);
+ if (blogCategory == null) return RedirectToAction(CategoryListAction);
+ if (!await categoryScope.HasAccess(blogCategory)) return RedirectToAction(CategoryListAction);
+
+ if (ModelState.IsValid)
+ {
+ if (categoryScope.DefaultStoreId is not null) model.Stores = [categoryScope.DefaultStoreId];
+ blogCategory = model.ToEntity(blogCategory);
+ blogCategory.SeName = SeoExtensions.GetSeName(
+ string.IsNullOrEmpty(blogCategory.SeName) ? blogCategory.Name : blogCategory.SeName,
+ seoSettings.ConvertNonWesternChars, seoSettings.AllowUnicodeCharsInUrls, seoSettings.SeoCharConversion);
+ await blogService.UpdateBlogCategory(blogCategory);
+ Success(translationService.GetResource("Admin.Content.Blog.BlogCategory.Updated"));
+ if (continueEditing)
+ {
+ await SaveSelectedTabIndex();
+ return RedirectToAction("CategoryEdit", new { id = blogCategory.Id });
+ }
+ return RedirectToAction(CategoryListAction);
+ }
+
+ ViewBag.AllLanguages = await languageService.GetAllLanguages(true);
+ await AddLocales(languageService, model.Locales, (locale, languageId) =>
+ {
+ locale.Name = blogCategory.GetTranslation(x => x.Name, languageId, false);
+ });
+ return View(model);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Delete)]
+ [HttpPost]
+ public async Task<IActionResult> CategoryDelete(string id)
+ {
+ var blogCategory = await blogService.GetBlogCategoryById(id);
+ if (blogCategory == null) return RedirectToAction(CategoryListAction);
+ if (!await categoryScope.HasAccess(blogCategory)) return RedirectToAction(CategoryListAction);
+
+ if (ModelState.IsValid)
+ {
+ await blogService.DeleteBlogCategory(blogCategory);
+ Success(translationService.GetResource("Admin.Content.Blog.BlogCategory.Deleted"));
+ return RedirectToAction(CategoryListAction);
+ }
+
+ Error(ModelState);
+ return RedirectToAction("CategoryEdit", new { id = blogCategory.Id });
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Preview)]
+ [HttpPost]
+ public async Task<IActionResult> CategoryPostList(string categoryId)
+ {
+ var blogCategory = await blogService.GetBlogCategoryById(categoryId);
+ if (blogCategory == null) return ErrorForKendoGridJson("blogCategory no exists");
+ if (!await categoryScope.HasAccess(blogCategory)) return ErrorForKendoGridJson(NoAccessToBlogCategoryMessage);
+
+ var blogposts = new List<Models.Blogs.BlogCategoryPost>();
+ foreach (var item in blogCategory.BlogPosts)
+ {
+ var post = new Models.Blogs.BlogCategoryPost { Id = item.Id, BlogPostId = item.BlogPostId };
+ var _post = await blogService.GetBlogPostById(item.BlogPostId);
+ if (_post != null) post.Name = _post.Title;
+ blogposts.Add(post);
+ }
+
+ var gridModel = new DataSourceResult {
+ Data = blogposts,
+ Total = blogCategory.BlogPosts.Count
+ };
+ return Json(gridModel);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Delete)]
+ public async Task<IActionResult> CategoryPostDelete(string categoryId, string id)
+ {
+ var blogCategory = await blogService.GetBlogCategoryById(categoryId);
+ if (blogCategory == null) return ErrorForKendoGridJson("blogCategory no exists");
+ if (!await categoryScope.HasAccess(blogCategory)) return ErrorForKendoGridJson(NoAccessToBlogCategoryMessage);
+
+ if (ModelState.IsValid)
+ {
+ var post = blogCategory.BlogPosts.FirstOrDefault(x => x.Id == id);
+ if (post != null)
+ {
+ blogCategory.BlogPosts.Remove(post);
+ await blogService.UpdateBlogCategory(blogCategory);
+ }
+ return new JsonResult("");
+ }
+
+ return ErrorForKendoGridJson(ModelState);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ public async Task<IActionResult> BlogPostAddPopup(string categoryId)
+ {
+ var model = new AddBlogPostCategoryModel { CategoryId = categoryId };
+ // Admin's original populates AvailableStores here; Store's original never does. Preserved as
+ // a genuine host divergence, gated the same way as every other DefaultStoreId-null check.
+ if (categoryScope.DefaultStoreId is null)
+ {
+ model.AvailableStores.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = " " });
+ foreach (var s in await storeService.GetAllStores())
+ model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });
+ }
+ return View(model);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ [HttpPost]
+ public async Task<IActionResult> BlogPostAddPopup(AddBlogPostCategoryModel model)
+ {
+ if (model.SelectedBlogPostIds == null) return Content("");
+
+ var blogCategory = await blogService.GetBlogCategoryById(model.CategoryId);
+ if (blogCategory == null) return Content("");
+ if (!await categoryScope.HasAccess(blogCategory)) return Content(NoAccessToBlogCategoryMessage);
+
+ foreach (var id in model.SelectedBlogPostIds)
+ {
+ var post = await blogService.GetBlogPostById(id);
+ if (post == null) continue;
+ // Skip (not fail) any individual post the current user can't access - a category owner
+ // can link only the posts they can see. Preserved from Store's original
+ // AddPostToBlogCategoryIfValid; Admin's original had no such check at all (postScope's
+ // GlobalAdminDataScope.HasAccess is always true, so the skip never fires for Admin).
+ if (!await postScope.HasAccess(post)) continue;
+ if (blogCategory.BlogPosts.Any(x => x.BlogPostId == id)) continue;
+
+ blogCategory.BlogPosts.Add(new Domain.Blogs.BlogCategoryPost { BlogPostId = id });
+ await blogService.UpdateBlogCategory(blogCategory);
+ }
+
+ return Content("");
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ [HttpPost]
+ public async Task<IActionResult> BlogPostAddPopupList(DataSourceRequest command, AddBlogPostCategoryModel model)
+ {
+ if (categoryScope.DefaultStoreId is not null) model.SearchStoreId = categoryScope.DefaultStoreId;
+
+ var gridModel = new DataSourceResult();
+ var posts = await blogService.GetAllBlogPosts(model.SearchStoreId, blogPostName: model.SearchBlogTitle,
+ pageIndex: command.Page - 1, pageSize: command.PageSize);
+ gridModel.Data = posts.Select(x => new { x.Id, Name = x.Title });
+ gridModel.Total = posts.TotalCount;
+ return Json(gridModel);
+ }
+
+ #endregion
+
+ #region Comments
+
+ public IActionResult Comments(string filterByBlogPostId)
+ {
+ ViewBag.FilterByBlogPostId = filterByBlogPostId;
+ return View();
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.List)]
+ [HttpPost]
+ public async Task<IActionResult> Comments(string filterByBlogPostId, DataSourceRequest command)
+ {
+ var model = await blogViewModelService.PrepareBlogPostCommentsModel(filterByBlogPostId, command.Page, command.PageSize);
+ var gridModel = new DataSourceResult {
+ Data = model.blogComments,
+ Total = model.totalCount
+ };
+ return Json(gridModel);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Delete)]
+ public async Task<IActionResult> CommentDelete(string id)
+ {
+ var comment = await blogService.GetBlogCommentById(id);
+ if (comment == null) throw new ArgumentException("No comment found with the specified id");
+
+ var blogPost = await blogService.GetBlogPostById(comment.BlogPostId);
+ if (blogPost == null) return ErrorForKendoGridJson("blogPost no exists");
+ if (!await postScope.HasAccess(blogPost)) return ErrorForKendoGridJson(NoAccessToBlogPostMessage);
+
+ if (ModelState.IsValid)
+ {
+ await blogService.DeleteBlogComment(comment);
+ var comments = await blogService.GetBlogCommentsByBlogPostId(blogPost.Id);
+ blogPost.CommentCount = comments.Count;
+ await blogService.UpdateBlogPost(blogPost);
+ return new JsonResult("");
+ }
+
+ return ErrorForKendoGridJson(ModelState);
+ }
+
+ #endregion
+
+ #region Products
+
+ [PermissionAuthorizeAction(PermissionActionName.List)]
+ [HttpPost]
+ public async Task<IActionResult> Products(string blogPostId, DataSourceRequest command)
+ {
+ var blogPost = await blogService.GetBlogPostById(blogPostId);
+ if (!await postScope.HasAccess(blogPost)) return ErrorForKendoGridJson(NoAccessToBlogPostMessage);
+
+ var model = await blogViewModelService.PrepareBlogProductsModel(blogPostId, command.Page, command.PageSize);
+ var gridModel = new DataSourceResult {
+ Data = model.blogProducts,
+ Total = model.totalCount
+ };
+ return Json(gridModel);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ public async Task<IActionResult> ProductAddPopup(string blogPostId)
+ {
+ var blogPost = await blogService.GetBlogPostById(blogPostId);
+ if (!await postScope.HasAccess(blogPost)) return Content(NoAccessToBlogPostMessage);
+
+ var model = await blogViewModelService.PrepareBlogModelAddProductModel(blogPostId);
+ return View(model);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ [HttpPost]
+ public async Task<IActionResult> ProductAddPopupList(DataSourceRequest command, BlogProductModel.AddProductModel model)
+ {
+ if (postScope.DefaultStoreId is not null) model.SearchStoreId = postScope.DefaultStoreId;
+
+ var products = await blogViewModelService.PrepareProductModel(model, command.Page, command.PageSize);
+ var gridModel = new DataSourceResult {
+ Data = products.products.ToList(),
+ Total = products.totalCount
+ };
+ return Json(gridModel);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ [HttpPost]
+ public async Task<IActionResult> ProductAddPopup(string blogPostId, BlogProductModel.AddProductModel model)
+ {
+ var blogPost = await blogService.GetBlogPostById(blogPostId);
+ if (!await postScope.HasAccess(blogPost)) return Content(NoAccessToBlogPostMessage);
+
+ if (model.SelectedProductIds != null) await blogViewModelService.InsertProductModel(blogPostId, model);
+ return Content("");
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Edit)]
+ public async Task<IActionResult> UpdateProduct(string blogPostId, BlogProductModel model)
+ {
+ var blogPost = await blogService.GetBlogPostById(blogPostId);
+ if (!await postScope.HasAccess(blogPost)) ModelState.AddModelError("Blog", NoAccessToBlogPostMessage);
+
+ if (ModelState.IsValid)
+ {
+ await blogViewModelService.UpdateProductModel(model);
+ return new JsonResult("");
+ }
+
+ return ErrorForKendoGridJson(ModelState);
+ }
+
+ [PermissionAuthorizeAction(PermissionActionName.Delete)]
+ public async Task<IActionResult> DeleteProduct(string id)
+ {
+ var bp = await blogService.GetBlogProductById(id) ?? throw new ArgumentException("No blog product found with the specified id");
+ var blogPost = await blogService.GetBlogPostById(bp.BlogPostId);
+ if (!await postScope.HasAccess(blogPost)) ModelState.AddModelError("Blog", NoAccessToBlogPostMessage);
+
+ if (ModelState.IsValid)
+ {
+ await blogViewModelService.DeleteProductModel(id);
+ return new JsonResult("");
+ }
+
+ return ErrorForKendoGridJson(ModelState);
+ }
+
+ #endregion
+}
diff --git a/src/Web/Grand.Web.AdminShared/Services/RoutedBlogCategoryDataScope.cs b/src/Web/Grand.Web.AdminShared/Services/RoutedBlogCategoryDataScope.cs
new file mode 100644
index 000000000..98821f00a
--- /dev/null
+++ b/src/Web/Grand.Web.AdminShared/Services/RoutedBlogCategoryDataScope.cs
@@ -0,0 +1,55 @@
+#nullable enable
+
+using Grand.Domain.Blogs;
+using Grand.Web.AdminShared.Interfaces;
+using Microsoft.AspNetCore.Http;
+
+namespace Grand.Web.AdminShared.Services;
+
+/// <summary>
+/// Resolves the correct per-host <see cref="IAdminDataScope{BlogCategory}" /> implementation at
+/// request time, based on the current request's "area" route value — same fix and same reason
+/// as <see cref="RoutedCategoryDataScope"/> (see that file's doc comment): Grand.Web (the
+/// combined host) loads Admin and Store together in one DI container, so a plain
+/// AddScoped&lt;IAdminDataScope&lt;BlogCategory&gt;, X&gt;() per host would silently let whichever
+/// host's StartupApplication ran last win for every area in that process.
+///
+/// No Vendor branch: Vendor has no Blog screen at all, so any "Vendor" (or other
+/// unrecognized/missing) area value fails closed.
+/// </summary>
+public class RoutedBlogCategoryDataScope(
+ IHttpContextAccessor httpContextAccessor,
+ GlobalAdminDataScope<BlogCategory> globalScope,
+ StoreAdminDataScope<BlogCategory> storeScope) : IAdminDataScope<BlogCategory>
+{
+ private IAdminDataScope<BlogCategory> Resolved
+ {
+ get
+ {
+ var area = httpContextAccessor.HttpContext?.Request.RouteValues["area"] as string;
+ return area switch {
+ "Admin" => globalScope,
+ "Store" => storeScope,
+ //fail closed: this object fronts store tenant isolation, so an unrecognized or
+ //missing area (including "Vendor" - BlogCategory has no Vendor screen) must never
+ //silently resolve to the unscoped global scope
+ _ => throw new InvalidOperationException(
+ $"RoutedBlogCategoryDataScope: unrecognized or missing area '{area}'.")
+ };
+ }
+ }
+
+ public Task<bool> HasAccess(BlogCategory entity) => Resolved.HasAccess(entity);
+
+ public Task<bool> CanView(BlogCategory entity) => Resolved.CanView(entity);
+
+ public string? DefaultStoreId => Resolved.DefaultStoreId;
+
+ public string ResourceKeyPrefix => Resolved.ResourceKeyPrefix;
+
+ public bool ShowStoreSelector => Resolved.ShowStoreSelector;
+
+ public string? DefaultVendorId => Resolved.DefaultVendorId;
+
+ public bool CanFeatureOnHomepage => Resolved.CanFeatureOnHomepage;
+}
diff --git a/src/Web/Grand.Web.AdminShared/Services/RoutedBlogPostDataScope.cs b/src/Web/Grand.Web.AdminShared/Services/RoutedBlogPostDataScope.cs
new file mode 100644
index 000000000..4d0ad8dc8
--- /dev/null
+++ b/src/Web/Grand.Web.AdminShared/Services/RoutedBlogPostDataScope.cs
@@ -0,0 +1,55 @@
+#nullable enable
+
+using Grand.Domain.Blogs;
+using Grand.Web.AdminShared.Interfaces;
+using Microsoft.AspNetCore.Http;
+
+namespace Grand.Web.AdminShared.Services;
+
+/// <summary>
+/// Resolves the correct per-host <see cref="IAdminDataScope{BlogPost}" /> implementation at
+/// request time, based on the current request's "area" route value — same fix and same reason
+/// as <see cref="RoutedCategoryDataScope"/> (see that file's doc comment): Grand.Web (the
+/// combined host) loads Admin and Store together in one DI container, so a plain
+/// AddScoped&lt;IAdminDataScope&lt;BlogPost&gt;, X&gt;() per host would silently let whichever
+/// host's StartupApplication ran last win for every area in that process.
+///
+/// No Vendor branch: Vendor has no Blog screen at all, so any "Vendor" (or other
+/// unrecognized/missing) area value fails closed.
+/// </summary>
+public class RoutedBlogPostDataScope(
+ IHttpContextAccessor httpContextAccessor,
+ GlobalAdminDataScope<BlogPost> globalScope,
+ StoreAdminDataScope<BlogPost> storeScope) : IAdminDataScope<BlogPost>
+{
+ private IAdminDataScope<BlogPost> Resolved
+ {
+ get
+ {
+ var area = httpContextAccessor.HttpContext?.Request.RouteValues["area"] as string;
+ return area switch {
+ "Admin" => globalScope,
+ "Store" => storeScope,
+ //fail closed: this object fronts store tenant isolation, so an unrecognized or
+ //missing area (including "Vendor" - BlogPost has no Vendor screen) must never
+ //silently resolve to the unscoped global scope
+ _ => throw new InvalidOperationException(
+ $"RoutedBlogPostDataScope: unrecognized or missing area '{area}'.")
+ };
+ }
+ }
+
+ public Task<bool> HasAccess(BlogPost entity) => Resolved.HasAccess(entity);
+
+ public Task<bool> CanView(BlogPost entity) => Resolved.CanView(entity);
+
+ public string? DefaultStoreId => Resolved.DefaultStoreId;
+
+ public string ResourceKeyPrefix => Resolved.ResourceKeyPrefix;
+
+ public bool ShowStoreSelector => Resolved.ShowStoreSelector;
+
+ public string? DefaultVendorId => Resolved.DefaultVendorId;
+
+ public bool CanFeatureOnHomepage => Resolved.CanFeatureOnHomepage;
+}
diff --git a/src/Web/Grand.Web.AdminShared/Startup/StartupApplication.cs b/src/Web/Grand.Web.AdminShared/Startup/StartupApplication.cs
index 7c6d91cbf..bd4adda49 100644
--- a/src/Web/Grand.Web.AdminShared/Startup/StartupApplication.cs
+++ b/src/Web/Grand.Web.AdminShared/Startup/StartupApplication.cs
@@ -1,5 +1,6 @@
using elFinder.Net.AspNetCore.Extensions;
using elFinder.Net.Drivers.FileSystem.Extensions;
+using Grand.Domain.Blogs;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Customers;
@@ -192,6 +193,18 @@ public class StartupApplication : IStartupApplication
services.AddScoped<GlobalAdminDataScope<SpecificationAttribute>>();
services.AddScoped<StoreAdminDataScope<SpecificationAttribute>>();
services.AddScoped<IAdminDataScope<SpecificationAttribute>, RoutedSpecificationAttributeDataScope>();
+
+ // IAdminDataScope<BlogPost>/<BlogCategory>: registered once here for the same reason as
+ // Category above — see RoutedBlogPostDataScope's doc comment. No Vendor scope: Blog has no
+ // Vendor screen. Two entities share one controller (BaseBlogController), so two routed
+ // scopes are registered.
+ services.AddScoped<GlobalAdminDataScope<BlogPost>>();
+ services.AddScoped<StoreAdminDataScope<BlogPost>>();
+ services.AddScoped<IAdminDataScope<BlogPost>, RoutedBlogPostDataScope>();
+
+ services.AddScoped<GlobalAdminDataScope<BlogCategory>>();
+ services.AddScoped<StoreAdminDataScope<BlogCategory>>();
+ services.AddScoped<IAdminDataScope<BlogCategory>, RoutedBlogCategoryDataScope>();
}
public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/BlogPostAddPopup.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/BlogPostAddPopup.cshtml
similarity index 88%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/BlogPostAddPopup.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/BlogPostAddPopup.cshtml
index 60ff60bbd..01be1d838 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/BlogPostAddPopup.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/BlogPostAddPopup.cshtml
@@ -1,12 +1,13 @@
-@model AddBlogPostCategoryModel
+@model AddBlogPostCategoryModel
@inject AdminAreaSettings adminAreaSettings
@{
Layout = "";
//page title
ViewBag.Title = Loc["Admin.Content.Blog.BlogCategory.AddNewPost"];
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
}
-<form id="BlogPostAddPopup" asp-area="@Constants.AreaAdmin" asp-controller="Blog" asp-action="BlogPostAddPopup" method="post"
+<form id="BlogPostAddPopup" asp-area="@area" asp-controller="Blog" asp-action="BlogPostAddPopup" method="post"
asp-route-CategoryId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["CategoryId"])"
asp-route-btnId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["btnId"])"
asp-route-formId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["formId"])">
@@ -29,12 +30,15 @@
<admin-input asp-for="SearchBlogTitle"/>
</div>
</div>
- <div class="form-group">
- <admin-label asp-for="SearchStoreId" class="col-sm-4 control-label"/>
- <div class="col-8 col-md-4 col-sm-4">
- <admin-select asp-for="SearchStoreId" asp-items="Model.AvailableStores"/>
+ @if (area == "Admin")
+ {
+ <div class="form-group">
+ <admin-label asp-for="SearchStoreId" class="col-sm-4 control-label"/>
+ <div class="col-8 col-md-4 col-sm-4">
+ <admin-select asp-for="SearchStoreId" asp-items="Model.AvailableStores"/>
+ </div>
</div>
- </div>
+ }
<div class="form-group">
<div class="offset-md-4 offset-sm-4 col-8 col-md-4 col-sm-4 mt-mobile-10">
<div class="btn-group btn-group-devided">
@@ -89,7 +93,7 @@
dataSource: {
transport: {
read: {
- url: "@Html.Raw(Url.Action("BlogPostAddPopupList", "Blog", new { area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("BlogPostAddPopupList", "Blog", new { area }))",
type: "POST",
dataType: "json",
data: additionalData
@@ -159,8 +163,11 @@
function additionalData() {
var data = {
- SearchBlogTitle: $('#@Html.IdFor(model => model.SearchBlogTitle)').val(),
- SearchStoreId: $('#SearchStoreId').val()
+ SearchBlogTitle: $('#@Html.IdFor(model => model.SearchBlogTitle)').val()
+ @if (area == "Admin")
+ {
+ <text>,SearchStoreId: $('#SearchStoreId').val()</text>
+ }
};
addAntiForgeryToken(data);
return data;
@@ -173,4 +180,4 @@
}
</script>
-</form>
\ No newline at end of file
+</form>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/CategoryCreate.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/CategoryCreate.cshtml
similarity index 84%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/CategoryCreate.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/CategoryCreate.cshtml
index 46558bdee..388906070 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/CategoryCreate.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/CategoryCreate.cshtml
@@ -1,9 +1,10 @@
-@model BlogCategoryModel
+@model BlogCategoryModel
@{
//page title
ViewBag.Title = Loc["Admin.Content.Blog.BlogCategory.AddNew"];
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
}
-<form asp-area="@Constants.AreaAdmin" asp-controller="Blog" asp-action="CategoryCreate" method="post">
+<form asp-area="@area" asp-controller="Blog" asp-action="CategoryCreate" method="post">
<div class="row">
<div class="col-md-12">
@@ -27,11 +28,11 @@
</div>
</div>
</div>
- <vc:admin-widget widget-zone="blog_category_buttons" additional-data="null"/>
+ <partial name="Partials/WidgetZone.CategoryButtonsCreate"/>
<div class="x_content form">
<partial name="Partials/CreateOrUpdateCategory" model="Model"/>
</div>
</div>
</div>
</div>
-</form>
\ No newline at end of file
+</form>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/CategoryEdit.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/CategoryEdit.cshtml
similarity index 85%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/CategoryEdit.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/CategoryEdit.cshtml
index 6f644e789..e0b78d1c1 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/CategoryEdit.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/CategoryEdit.cshtml
@@ -1,10 +1,11 @@
-@model BlogCategoryModel
+@model BlogCategoryModel
@{
//page title
ViewBag.Title = Loc["Admin.Content.Blog.BlogCategory.EditBlogCategoryDetails"];
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
}
-<form asp-area="@Constants.AreaAdmin" asp-controller="Blog" asp-action="CategoryEdit" method="post" id="category-form">
+<form asp-area="@area" asp-controller="Blog" asp-action="CategoryEdit" method="post" id="category-form">
<div class="row">
<div class="col-md-12">
@@ -31,7 +32,7 @@
</div>
</div>
</div>
- <vc:admin-widget widget-zone="blog_category_buttons" additional-data="Model"/>
+ <partial name="Partials/WidgetZone.CategoryButtons" model="Model"/>
<div class="x_content form">
<partial name="Partials/CreateOrUpdateCategory" model="Model"/>
</div>
@@ -39,4 +40,4 @@
</div>
</div>
</form>
-<admin-delete-confirmation button-id="blogcategory-delete" action-name="CategoryDelete"/>
\ No newline at end of file
+<admin-delete-confirmation button-id="blogcategory-delete" action-name="CategoryDelete"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/CategoryList.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/CategoryList.cshtml
similarity index 93%
rename from src/Web/Grand.Web.Store/Areas/Store/Views/Blog/CategoryList.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/CategoryList.cshtml
index 3b76a7afd..edadcaf74 100644
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/CategoryList.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/CategoryList.cshtml
@@ -1,7 +1,8 @@
-@inject AdminAreaSettings adminAreaSettings
+@inject AdminAreaSettings adminAreaSettings
@{
//page title
ViewBag.Title = Loc["Admin.Content.Blog.BlogCategories"];
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
}
<div class="row">
@@ -13,7 +14,7 @@
@Loc["Admin.Content.Blog.BlogCategories"]
</div>
<div class="actions btn-group btn-group-devided">
- <a href="@Url.Action("CategoryCreate", new { area = Constants.AreaStore })" class="btn green">
+ <a href="@Url.Action("CategoryCreate", new { area })" class="btn green">
<i class="fa fa-plus"></i><span class="d-none d-sm-inline"> @Loc["Admin.Common.AddNew"] </span>
</a>
</div>
@@ -37,7 +38,7 @@
dataSource: {
transport: {
read: {
- url: "@Html.Raw(Url.Action("CategoryList", "Blog", new { area = Constants.AreaStore }))",
+ url: "@Html.Raw(Url.Action("CategoryList", "Blog", new { area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
@@ -78,8 +79,8 @@
headerAttributes: { style: "text-align:center" },
attributes: { style: "text-align:center" },
title: "@Loc["Admin.Content.Blog.BlogCategory.Fields.DisplayOrder"]",
- width: 100,
+ width: 100,
}]
});
});
-</script>
\ No newline at end of file
+</script>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Comments.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Comments.cshtml
similarity index 88%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Comments.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Comments.cshtml
index 1599d34dc..9d119284e 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Comments.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Comments.cshtml
@@ -1,8 +1,9 @@
-@inject AdminAreaSettings adminAreaSettings
+@inject AdminAreaSettings adminAreaSettings
@{
//page title
ViewBag.Title = Loc["Admin.Content.Blog.Comments"];
string filterByBlogPostId = ViewBag.FilterByBlogPostId;
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
}
<div class="row">
@@ -28,7 +29,7 @@
</div>
@{
- var readUrl = !string.IsNullOrEmpty(filterByBlogPostId) ? Url.Action("Comments", "Blog", new { filterByBlogPostId, area = Constants.AreaAdmin }) : Url.Action("Comments", "Blog", new { area = Constants.AreaAdmin });
+ var readUrl = !string.IsNullOrEmpty(filterByBlogPostId) ? Url.Action("Comments", "Blog", new { filterByBlogPostId, area }) : Url.Action("Comments", "Blog", new { area });
}
<script>
$(document).ready(function () {
@@ -42,7 +43,7 @@
data: addAntiForgeryToken
},
destroy: {
- url: "@Html.Raw(Url.Action("CommentDelete", "Blog", new { area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("CommentDelete", "Blog", new { area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
@@ -86,12 +87,12 @@
title: "@Loc["Admin.Content.Blog.Comments.Fields.BlogPost"]",
width: 200,
encoded: false,
- template: '<a class="k-link" href="@Url.Action("Edit", "Blog", new { area = Constants.AreaAdmin })/#=BlogPostId#">#:kendo.htmlEncode(BlogPostTitle)#</a>'
+ template: '<a class="k-link" href="@Url.Action("Edit", "Blog", new { area })/#=BlogPostId#">#:kendo.htmlEncode(BlogPostTitle)#</a>'
}, {
field: "CustomerId",
title: "@Loc["Admin.Content.Blog.Comments.Fields.Customer"]",
width: 200,
- template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area = Constants.AreaAdmin })/#=CustomerId#">#:kendo.htmlEncode(CustomerInfo)#</a>'
+ template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area })/#=CustomerId#">#:kendo.htmlEncode(CustomerInfo)#</a>'
}, {
field: "Comment",
title: "@Loc["Admin.Content.Blog.Comments.Fields.Comment"]",
@@ -109,4 +110,4 @@
}]
});
});
-</script>
\ No newline at end of file
+</script>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Create.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Create.cshtml
similarity index 85%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Create.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Create.cshtml
index bc9ca160a..aa035d5a7 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Create.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Create.cshtml
@@ -1,9 +1,10 @@
-@model BlogPostModel
+@model BlogPostModel
@{
//page title
ViewBag.Title = Loc["Admin.Content.Blog.BlogPosts.AddNew"];
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
}
-<form asp-area="@Constants.AreaAdmin" asp-controller="Blog" asp-action="Create" method="post">
+<form asp-area="@area" asp-controller="Blog" asp-action="Create" method="post">
<div class="row">
<div class="col-md-12">
@@ -27,11 +28,11 @@
</div>
</div>
</div>
- <vc:admin-widget widget-zone="blog_details_buttons" additional-data="null"/>
+ <partial name="Partials/WidgetZone.DetailsButtonsCreate"/>
<div class="x_content form">
<partial name="Partials/CreateOrUpdate" model="Model"/>
</div>
</div>
</div>
</div>
-</form>
\ No newline at end of file
+</form>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Edit.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Edit.cshtml
similarity index 86%
rename from src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Edit.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Edit.cshtml
index cb19d53d5..335918f08 100644
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Edit.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Edit.cshtml
@@ -1,10 +1,11 @@
-@model BlogPostModel
+@model BlogPostModel
@{
//page title
ViewBag.Title = Loc["Admin.Content.Blog.BlogPosts.EditBlogPostDetails"];
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
}
-<form asp-area="@Constants.AreaStore" asp-controller="Blog" asp-action="Edit" method="post" id="blog-edit">
+<form asp-area="@area" asp-controller="Blog" asp-action="Edit" method="post" id="blog-edit">
<div class="row">
<div class="col-md-12">
@@ -35,7 +36,7 @@
</div>
</div>
</div>
- <vc:admin-widget widget-zone="blog_details_buttons" additional-data="Model"/>
+ <partial name="Partials/WidgetZone.DetailsButtons" model="Model"/>
<div class="x_content form">
<partial name="Partials/CreateOrUpdate" model="Model"/>
</div>
@@ -43,4 +44,4 @@
</div>
</div>
</form>
-<admin-delete-confirmation button-id="blogpost-delete"/>
\ No newline at end of file
+<admin-delete-confirmation button-id="blogpost-delete"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/List.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/List.cshtml
similarity index 93%
rename from src/Web/Grand.Web.Store/Areas/Store/Views/Blog/List.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/List.cshtml
index 764550bb4..a9083ce40 100644
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/List.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/List.cshtml
@@ -1,7 +1,8 @@
-@inject AdminAreaSettings adminAreaSettings
+@inject AdminAreaSettings adminAreaSettings
@{
//page title
ViewBag.Title = Loc["Admin.Content.Blog.BlogPosts"];
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
}
<div class="row">
@@ -13,7 +14,7 @@
@Loc["Admin.Content.Blog.BlogPosts"]
</div>
<div class="actions btn-group btn-group-devided">
- <a href="@Url.Action("Create", new { area = Constants.AreaStore })" class="btn green">
+ <a href="@Url.Action("Create", new { area })" class="btn green">
<i class="fa fa-plus"></i><span class="d-none d-sm-inline"> @Loc["Admin.Common.AddNew"] </span>
</a>
</div>
@@ -37,7 +38,7 @@
dataSource: {
transport: {
read: {
- url: "@Html.Raw(Url.Action("List", "Blog", new { area = Constants.AreaStore }))",
+ url: "@Html.Raw(Url.Action("List", "Blog", new { area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
@@ -98,4 +99,4 @@
}]
});
});
-</script>
\ No newline at end of file
+</script>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabComments.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabComments.cshtml
similarity index 87%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabComments.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabComments.cshtml
index 53059ddee..d46aa1408 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabComments.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabComments.cshtml
@@ -1,13 +1,16 @@
-@model BlogPostModel
+@model BlogPostModel
@inject AdminAreaSettings adminAreaSettings
+@{
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
+}
@if (!string.IsNullOrEmpty(Model.Id))
{
<div class="panel panel-default">
- <vc:admin-widget widget-zone="blog_details_comments_top" additional-data="Model"/>
+ <partial name="Partials/WidgetZone.Comments.Top" model="Model"/>
<div class="panel-body">
<div id="comments-grid"></div>
</div>
- <vc:admin-widget widget-zone="blog_details_comments_bottom" additional-data="Model"/>
+ <partial name="Partials/WidgetZone.Comments.Bottom" model="Model"/>
</div>
<script>
@@ -16,13 +19,13 @@
dataSource: {
transport: {
read: {
- url: "@Url.Action("Comments", "Blog", new { filterByBlogPostId = Model.Id, area = Constants.AreaAdmin })",
+ url: "@Url.Action("Comments", "Blog", new { filterByBlogPostId = Model.Id, area })",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
},
destroy: {
- url: "@Html.Raw(Url.Action("CommentDelete", "Blog", new { area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("CommentDelete", "Blog", new { area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
@@ -65,7 +68,7 @@
field: "CustomerId",
title: "@Loc["Admin.Content.Blog.Comments.Fields.Customer"]",
width: 200,
- template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area = Constants.AreaAdmin })/#=CustomerId#">#:kendo.htmlEncode(CustomerInfo)#</a>'
+ template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area })/#=CustomerId#">#:kendo.htmlEncode(CustomerInfo)#</a>'
}, {
field: "Comment",
title: "@Loc["Admin.Content.Blog.Comments.Fields.Comment"]",
@@ -90,4 +93,4 @@ else
<div class="note note-info">
@Loc["Admin.Content.Blog.BlogPosts.SaveBeforeEdit"]
</div>
-}
\ No newline at end of file
+}
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabInfo.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabInfo.cshtml
similarity index 90%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabInfo.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabInfo.cshtml
index c3550fde7..d7d0b68c6 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabInfo.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabInfo.cshtml
@@ -1,7 +1,11 @@
-@using System.Text.Encodings.Web
+@using System.Text.Encodings.Web
@using Microsoft.AspNetCore.Mvc.Razor
+@using Grand.Business.Core.Interfaces.Cms
@model BlogPostModel
@inject IBlogService blogService
+@{
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
+}
<script>
@{
@@ -67,7 +71,7 @@
}
<div class="form-horizontal">
- <vc:admin-widget widget-zone="blog_details_info_top" additional-data="Model"/>
+ <partial name="Partials/WidgetZone.Info.Top" model="Model"/>
<localized-editor localized-template="@template" name="blogpost-info-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">
<div class="form-body">
<div class="form-group">
@@ -105,7 +109,7 @@
@if (!string.IsNullOrEmpty(Model.PictureId))
{
<label class="control-label">
- <a class='k-link picturelink' href='@Url.Action("PicturePopup", "Blog", new { area = Constants.AreaAdmin })/?blogpostId=@(Model.Id)'>@Loc["Admin.Common.Picture.Attributes"]</a>
+ <a class='k-link picturelink' href='@Url.Action("PicturePopup", "Blog", new { area })/?blogpostId=@(Model.Id)'>@Loc["Admin.Common.Picture.Attributes"]</a>
</label>
<script>
$(document).ready(function () {
@@ -166,12 +170,15 @@
<span asp-validation-for="EndDate"></span>
</div>
</div>
- <div class="form-group">
- <admin-label asp-for="Stores"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="Stores"/>
- <span asp-validation-for="Stores"></span>
+ @if (area == "Admin")
+ {
+ <div class="form-group">
+ <admin-label asp-for="Stores"/>
+ <div class="col-md-9 col-sm-9">
+ <admin-input asp-for="Stores"/>
+ <span asp-validation-for="Stores"></span>
+ </div>
</div>
- </div>
- <vc:admin-widget widget-zone="blog_details_info_bottom" additional-data="Model"/>
-</div>
\ No newline at end of file
+ }
+ <partial name="Partials/WidgetZone.Info.Bottom" model="Model"/>
+</div>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabProducts.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabProducts.cshtml
similarity index 87%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabProducts.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabProducts.cshtml
index 3ea362882..fc327736a 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabProducts.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabProducts.cshtml
@@ -1,17 +1,20 @@
-@model BlogPostModel
+@model BlogPostModel
@inject AdminAreaSettings adminAreaSettings
+@{
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
+}
@if (!string.IsNullOrEmpty(Model.Id))
{
<div class="panel panel-default">
- <vc:admin-widget widget-zone="blog_details_product_top" additional-data="Model"/>
+ <partial name="Partials/WidgetZone.Products.Top" model="Model"/>
<div class="panel-body">
<div id="product-grid"></div>
</div>
<div class="panel-footer">
- <a id="btnAddNewProduct" href="@(Url.Action("ProductAddPopup", "Blog", new { blogPostId = Model.Id, btnId = "btnRefreshProducts", formId = "blog-edit", area = Constants.AreaAdmin }))" class="k-button"><i class="fa fa-plus"></i>&nbsp;@Loc["Admin.Content.Blog.BlogPosts.Products.AddNew"]</a>
+ <a id="btnAddNewProduct" href="@(Url.Action("ProductAddPopup", "Blog", new { blogPostId = Model.Id, btnId = "btnRefreshProducts", formId = "blog-edit", area }))" class="k-button"><i class="fa fa-plus"></i>&nbsp;@Loc["Admin.Content.Blog.BlogPosts.Products.AddNew"]</a>
<input type="button" id="btnRefreshProducts" style="display: none"/>
</div>
- <vc:admin-widget widget-zone="blog_details_product_bottom" additional-data="Model"/>
+ <partial name="Partials/WidgetZone.Products.Bottom" model="Model"/>
</div>
<script>
$(document).ready(function () {
@@ -32,19 +35,19 @@
dataSource: {
transport: {
read: {
- url: "@Html.Raw(Url.Action("Products", "Blog", new { blogPostId = Model.Id, area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("Products", "Blog", new { blogPostId = Model.Id, area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
},
update: {
- url:"@Html.Raw(Url.Action("UpdateProduct", "Blog", new { area = Constants.AreaAdmin }))",
+ url:"@Html.Raw(Url.Action("UpdateProduct", "Blog", new { blogPostId = Model.Id, area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
},
destroy: {
- url: "@Html.Raw(Url.Action("DeleteProduct", "Blog", new { area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("DeleteProduct", "Blog", new { area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
@@ -85,7 +88,7 @@
field: "ProductName",
title: "@Loc["Admin.Content.Blog.Product.Fields.ProductName"]",
width: 300,
- template: '<a href="@Url.Action("Edit", "Product", new { area = Constants.AreaAdmin })/#=ProductId#" target="_blank">#=kendo.htmlEncode(ProductName)#</a>'
+ template: '<a href="@Url.Action("Edit", "Product", new { area })/#=ProductId#" target="_blank">#=kendo.htmlEncode(ProductName)#</a>'
}, {
field: "DisplayOrder",
title: "@Loc["Admin.Content.Blog.Product.Fields.DisplayOrder"]",
@@ -125,4 +128,4 @@ else
<div class="note note-info">
@Loc["Admin.Content.Blog.BlogPosts.SaveBeforeEdit"]
</div>
-}
\ No newline at end of file
+}
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabSeo.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabSeo.cshtml
similarity index 94%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabSeo.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabSeo.cshtml
index 1fef5cb5b..219dadf90 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.TabSeo.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.TabSeo.cshtml
@@ -1,7 +1,7 @@
-@using Microsoft.AspNetCore.Mvc.Razor
+@using Microsoft.AspNetCore.Mvc.Razor
@model BlogPostModel
-<vc:admin-widget widget-zone="blog_details_seo_top" additional-data="Model"/>
+<partial name="Partials/WidgetZone.SEO.Top" model="Model"/>
@{
Func<int, HelperResult>
template = @<div class="form-body">
@@ -72,4 +72,4 @@
</localized-editor>
</div>
-<vc:admin-widget widget-zone="blog_details_seo_bottom" additional-data="Model"/>
\ No newline at end of file
+<partial name="Partials/WidgetZone.SEO.Bottom" model="Model"/>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.cshtml
similarity index 89%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.cshtml
index 460720ba7..6843f61b6 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdate.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdate.cshtml
@@ -1,8 +1,11 @@
-@model BlogPostModel
+@model BlogPostModel
+@{
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
+}
<div asp-validation-summary="All"></div>
<input asp-for="Id" type="hidden"/>
-<input id="active-menu-item" type="hidden" value="/@Constants.AreaAdmin/Blog/List"/>
+<input id="active-menu-item" type="hidden" value="/@area/Blog/List"/>
<admin-tabstrip name="blog-post-edit">
<items>
@@ -41,10 +44,10 @@
</div>
</content>
</tabstrip-item>
- <vc:admin-widget widget-zone="blog_details_tabs" additional-data="Model"/>
+ <partial name="Partials/WidgetZone.Tabs" model="Model"/>
</items>
</admin-tabstrip>
<link rel="stylesheet" type="text/css" asp-src="@(Grand.SharedUIResources.Constants.WwwRoot)/administration/tagEditor/jquery.tag-editor.css"/>
<script asp-location="Footer" asp-src="@(Grand.SharedUIResources.Constants.WwwRoot)/administration/tagEditor/jquery.tag-editor.min.js"></script>
-<script asp-location="Footer" asp-src="@(Grand.SharedUIResources.Constants.WwwRoot)/administration/tagEditor/jquery.caret.min.js"></script>
\ No newline at end of file
+<script asp-location="Footer" asp-src="@(Grand.SharedUIResources.Constants.WwwRoot)/administration/tagEditor/jquery.caret.min.js"></script>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdateCategory.Posts.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdateCategory.Posts.cshtml
similarity index 89%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdateCategory.Posts.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdateCategory.Posts.cshtml
index b5fa52d8a..290946025 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdateCategory.Posts.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdateCategory.Posts.cshtml
@@ -1,6 +1,9 @@
-@model BlogCategoryModel
+@model BlogCategoryModel
@inject AdminAreaSettings adminAreaSettings
+@{
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
+}
@if (!string.IsNullOrEmpty(Model.Id))
{
<div class="panel panel-default">
@@ -8,7 +11,7 @@
<div id="posts-grid"></div>
</div>
<div class="panel-footer">
- <a id="btnAddNewPost" href="@(Url.Action("BlogPostAddPopup", "Blog", new { categoryId = Model.Id, btnId = "btnRefreshPosts", formId = "category-form", area = Constants.AreaAdmin }))" class="k-button"><i class="fa fa-plus"></i>&nbsp;@Loc["Admin.Content.Blog.BlogCategory.AddNewPost"]</a>
+ <a id="btnAddNewPost" href="@(Url.Action("BlogPostAddPopup", "Blog", new { categoryId = Model.Id, btnId = "btnRefreshPosts", formId = "category-form", area }))" class="k-button"><i class="fa fa-plus"></i>&nbsp;@Loc["Admin.Content.Blog.BlogCategory.AddNewPost"]</a>
<input type="submit" id="btnRefreshPosts" style="display: none"/>
</div>
</div>
@@ -31,13 +34,13 @@
dataSource: {
transport: {
read: {
- url: "@Html.Raw(Url.Action("CategoryPostList", "Blog", new { categoryId = Model.Id, area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("CategoryPostList", "Blog", new { categoryId = Model.Id, area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
},
destroy: {
- url: "@Html.Raw(Url.Action("CategoryPostDelete", "Blog", new { categoryId = Model.Id, area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("CategoryPostDelete", "Blog", new { categoryId = Model.Id, area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
@@ -82,7 +85,7 @@
columns: [{
field: "Name",
title: "@Loc["Admin.Content.Blog.BlogCategory.Fields.Post"]",
- template: '<a class="k-link" href="@Url.Action("Edit", "Blog", new { area = Constants.AreaAdmin })/#=BlogPostId#">#=kendo.htmlEncode(Name)#</a>',
+ template: '<a class="k-link" href="@Url.Action("Edit", "Blog", new { area })/#=BlogPostId#">#=kendo.htmlEncode(Name)#</a>',
},{
command: [{
name: "destroy",
@@ -109,4 +112,4 @@ else
<div class="note note-info">
@Loc["Admin.Content.Blog.BlogCategory.SaveBeforeEdit"]
</div>
-}
\ No newline at end of file
+}
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdateCategory.TabInfo.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdateCategory.TabInfo.cshtml
similarity index 74%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdateCategory.TabInfo.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdateCategory.TabInfo.cshtml
index 982b92ff9..44973aa21 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Partials/CreateOrUpdateCategory.TabInfo.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdateCategory.TabInfo.cshtml
@@ -1,6 +1,8 @@
-@using Microsoft.AspNetCore.Mvc.Razor
+@using Microsoft.AspNetCore.Mvc.Razor
@model BlogCategoryModel
-
+@{
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
+}
@{
Func<int, HelperResult>
@@ -17,7 +19,7 @@
}
<div class="form-horizontal">
- <vc:admin-widget widget-zone="blog_category_info_top" additional-data="Model"/>
+ <partial name="Partials/WidgetZone.CategoryInfo.Top" model="Model"/>
<localized-editor localized-template="@template" name="blogcategory-info-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">
<div class="form-body">
<div class="form-group">
@@ -43,12 +45,15 @@
<span asp-validation-for="DisplayOrder"></span>
</div>
</div>
- <div class="form-group">
- <admin-label asp-for="Stores"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="Stores"/>
- <span asp-validation-for="Stores"></span>
+ @if (area == "Admin")
+ {
+ <div class="form-group">
+ <admin-label asp-for="Stores"/>
+ <div class="col-md-9 col-sm-9">
+ <admin-input asp-for="Stores"/>
+ <span asp-validation-for="Stores"></span>
+ </div>
</div>
- </div>
- <vc:admin-widget widget-zone="blog_category_info_bottom" additional-data="Model"/>
-</div>
\ No newline at end of file
+ }
+ <partial name="Partials/WidgetZone.CategoryInfo.Bottom" model="Model"/>
+</div>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdateCategory.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdateCategory.cshtml
similarity index 84%
rename from src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdateCategory.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdateCategory.cshtml
index 2271f47aa..f2786c4f0 100644
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdateCategory.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/Partials/CreateOrUpdateCategory.cshtml
@@ -1,4 +1,4 @@
-@model BlogCategoryModel
+@model BlogCategoryModel
<div asp-validation-summary="All"></div>
<input asp-for="Id" type="hidden"/>
@@ -18,6 +18,6 @@
</div>
</content>
</tabstrip-item>
- <vc:admin-widget widget-zone="blog_category_details_tabs" additional-data="Model"/>
+ <partial name="Partials/WidgetZone.CategoryTabs" model="Model"/>
</items>
-</admin-tabstrip>
\ No newline at end of file
+</admin-tabstrip>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/ProductAddPopup.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/ProductAddPopup.cshtml
similarity index 87%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/ProductAddPopup.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/ProductAddPopup.cshtml
index 1a84916d9..994d7ce0a 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/ProductAddPopup.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Blog/ProductAddPopup.cshtml
@@ -1,12 +1,13 @@
-@model BlogProductModel.AddProductModel
+@model BlogProductModel.AddProductModel
@inject AdminAreaSettings adminAreaSettings
@{
Layout = "";
//page title
ViewBag.Title = Loc["Admin.Content.Blog.BlogPosts.Products.AddNew"];
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
}
-<form id="ProductAddPopup" asp-area="@Constants.AreaAdmin" asp-controller="Blog" asp-action="ProductAddPopup" method="post"
+<form id="ProductAddPopup" asp-area="@area" asp-controller="Blog" asp-action="ProductAddPopup" method="post"
asp-route-BlogPostId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["BlogPostId"])"
asp-route-btnId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["btnId"])"
asp-route-formId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["formId"])">
@@ -66,18 +67,21 @@
<admin-input asp-for="SearchBrandId"/>
</div>
</div>
- <div class="form-group">
- <admin-label asp-for="SearchStoreId" class="col-sm-3 control-label"/>
- <div class="col-md-9 col-sm-9">
- <admin-select asp-for="SearchStoreId" asp-items="Model.AvailableStores"/>
+ @if (area == "Admin")
+ {
+ <div class="form-group">
+ <admin-label asp-for="SearchStoreId" class="col-sm-3 control-label"/>
+ <div class="col-md-9 col-sm-9">
+ <admin-select asp-for="SearchStoreId" asp-items="Model.AvailableStores"/>
+ </div>
</div>
- </div>
- <div class="form-group">
- <admin-label asp-for="SearchVendorId" class="col-sm-3 control-label"/>
- <div class="col-md-9 col-sm-9">
- <admin-select asp-for="SearchVendorId" asp-items="Model.AvailableVendors"/>
+ <div class="form-group">
+ <admin-label asp-for="SearchVendorId" class="col-sm-3 control-label"/>
+ <div class="col-md-9 col-sm-9">
+ <admin-select asp-for="SearchVendorId" asp-items="Model.AvailableVendors"/>
+ </div>
</div>
- </div>
+ }
<div class="form-group">
<admin-label asp-for="SearchProductTypeId" class="col-sm-3 control-label"/>
<div class="col-md-9 col-sm-9">
@@ -135,7 +139,7 @@
dataSource: {
transport: {
read: {
- url: "@Html.Raw(Url.Action("ProductAddPopupList", "Blog", new { area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("ProductAddPopupList", "Blog", new { area }))",
type: "POST",
dataType: "json",
data: additionalData
@@ -217,8 +221,11 @@
SearchCategoryId: $('#SearchCategoryId').val(),
SearchBrandId: $('#SearchBrandId').val(),
SearchCollectionId: $('#SearchCollectionId').val(),
- SearchStoreId: $('#SearchStoreId').val(),
- SearchVendorId: $('#SearchVendorId').val(),
+ @if (area == "Admin")
+ {
+ <text>SearchStoreId: $('#SearchStoreId').val(),
+ SearchVendorId: $('#SearchVendorId').val(),</text>
+ }
SearchProductTypeId: $('#SearchProductTypeId').val()
};
addAntiForgeryToken(data);
@@ -232,4 +239,4 @@
}
</script>
-</form>
\ No newline at end of file
+</form>
diff --git a/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml
index 70a550d2f..076e64751 100644
--- a/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml
@@ -13,6 +13,7 @@
@using Grand.Web.Common
@using Grand.Web.Common.Extensions
@using Grand.Web.Common.Localization
+@using Grand.Web.AdminShared.Models.Blogs
@using Grand.Web.AdminShared.Models.Catalog
@using Grand.Web.AdminShared.Models.Orders
@using Grand.Web.AdminShared.Models.Customers
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/BlogPostAddPopup.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/BlogPostAddPopup.cshtml
deleted file mode 100644
index 048f14a2d..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/BlogPostAddPopup.cshtml
+++ /dev/null
@@ -1,169 +0,0 @@
-@model AddBlogPostCategoryModel
-@inject AdminAreaSettings adminAreaSettings
-
-@{
- Layout = "";
- //page title
- ViewBag.Title = Loc["Admin.Content.Blog.BlogCategory.AddNewPost"];
-}
-<form id="BlogPostAddPopup" asp-area="@Constants.AreaStore" asp-controller="Blog" asp-action="BlogPostAddPopup" method="post"
- asp-route-CategoryId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["CategoryId"])"
- asp-route-btnId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["btnId"])"
- asp-route-formId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["formId"])">
-
- <div class="row">
- <div class="col-md-12">
- <div class="x_panel light form-fit">
- <div class="x_title">
- <div class="caption">
- <i class="fa fa-sitemap"></i>
- @Loc["Admin.Content.Blog.BlogCategory.AddNewPost"]
- </div>
- </div>
- <div class="x_content form">
- <div class="form-horizontal">
- <div class="form-body">
- <div class="form-group">
- <admin-label asp-for="SearchBlogTitle" class="col-sm-4 control-label"/>
- <div class="col-8 col-md-4 col-sm-4">
- <admin-input asp-for="SearchBlogTitle"/>
- </div>
- </div>
- <div class="form-group">
- <div class="offset-md-4 offset-sm-4 col-8 col-md-4 col-sm-4 mt-mobile-10">
- <div class="btn-group btn-group-devided">
- <button class="btn btn-success filter-submit" id="search-posts">
- <i class="fa fa-search"></i> @Loc["Admin.Common.Search"]
- </button>
- <button class="btn btn-success" type="submit" name="save">
- <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]
- </button>
- </div>
- </div>
- </div>
- <div id="blogposts-grid"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script>
- var mfp = $.magnificPopup.instance;
- $("#BlogPostAddPopup").submit(function (e) {
- e.preventDefault();
- var form = $(this);
- var url = form.attr('action');
- $.ajax({
- type: "POST",
- url: url,
- data: form.serialize(),
- success: function (data) {
- if (data == "") {
- mfp.close();
- $('#btnRefreshPosts').click();
- } else {
- $.magnificPopup.open({
- items: {
- src: data,
- type: 'inline'
- },
- callbacks: {
- open: function () {
- $('.mfp-wrap').removeAttr('tabindex');
- }
- }
- });
- }
- }
- });
- });
-
- $("#blogposts-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("BlogPostAddPopupList", "Blog", new { area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: additionalData
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors"
- },
- error: function(e) {
- display_kendoui_grid_error(e);
- // Cancel the changes
- this.cancelChanges();
- },
- pageSize: @(adminAreaSettings.DefaultGridPageSize),
- serverPaging: true,
- serverFiltering: true,
- serverSorting: true
- },
- pageable: {
- refresh: true,
- pageSizes: [@(adminAreaSettings.GridPageSizes)]
- },
- editable: {
- confirmation: false,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "Id",
- headerTemplate: "<input id='mastercheckbox' type='checkbox'/>",
- headerAttributes: { style: "text-align:center" },
- template: "<input type='checkbox' name='SelectedBlogPostIds' value='#=Id#' class='checkboxGroups' />",
- attributes: { style: "text-align:center" },
- width: 50
- }, {
- field: "Name",
- title: "@Loc["Admin.Content.Blog.BlogCategory.Fields.Post"]"
- }]
- });
-
- $('#search-posts').click(function() {
- var grid = $('#blogposts-grid').data('kendoGrid');
- grid.dataSource.page(1); //new search. Set page size to 1
- //grid.dataSource.read(); we already loaded the grid above using "page" function
- //clear selected checkboxes
- $('.checkboxGroups').prop('checked', false).change();
- return false;
- });
-
- $("#@Html.IdFor(model => model.SearchBlogTitle)").keydown(function(event) {
- if (event.keyCode == 13) {
- $("#search-posts").click();
- return false;
- }
- });
-
- //wire up checkboxes
- $('#mastercheckbox').click(function() {
- $('.checkboxGroups').prop('checked', $(this).is(':checked')).change();
- });
-
- $('#blogposts-grid').on('change', 'input[type=checkbox][id!=mastercheckbox]', function(e) {
- updateMasterCheckbox();
- });
-
- function additionalData() {
- var data = {
- SearchBlogTitle: $('#@Html.IdFor(model => model.SearchBlogTitle)').val()
- };
- addAntiForgeryToken(data);
- return data;
- }
-
- function updateMasterCheckbox() {
- var numChkBoxes = $('#blogposts-grid input[type=checkbox][id!=mastercheckbox]').length;
- var numChkBoxesChecked = $('#blogposts-grid input[type=checkbox][id!=mastercheckbox]:checked').length;
- $('#mastercheckbox').prop('checked', numChkBoxes == numChkBoxesChecked && numChkBoxes > 0);
- }
-
- </script>
-</form>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/CategoryCreate.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/CategoryCreate.cshtml
deleted file mode 100644
index ee5ec727a..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/CategoryCreate.cshtml
+++ /dev/null
@@ -1,37 +0,0 @@
-@model BlogCategoryModel
-@{
- //page title
- ViewBag.Title = Loc["Admin.Content.Blog.BlogCategory.AddNew"];
-}
-<form asp-area="@Constants.AreaStore" asp-controller="Blog" asp-action="CategoryCreate" method="post">
-
- <div class="row">
- <div class="col-md-12">
- <div class="x_panel light form-fit">
- <div class="x_title">
- <div class="caption">
- <i class="fa fa-comment"></i>
- @Loc["Admin.Content.Blog.BlogCategory.AddNew"]
- <small>
- <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Content.Blog.BlogCategory.BackToList"], "List")
- </small>
- </div>
- <div class="actions">
- <div class="btn-group btn-group-devided">
- <button class="btn btn-success" type="submit" name="save">
- <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]
- </button>
- <button class="btn btn-success" type="submit" name="save-continue">
- <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]
- </button>
- </div>
- </div>
- </div>
- <vc:admin-widget widget-zone="blog_category_buttons" additional-data="null"/>
- <div class="x_content form">
- <partial name="Partials/CreateOrUpdateCategory" model="Model"/>
- </div>
- </div>
- </div>
- </div>
-</form>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/CategoryEdit.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/CategoryEdit.cshtml
deleted file mode 100644
index 21a638b94..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/CategoryEdit.cshtml
+++ /dev/null
@@ -1,42 +0,0 @@
-@model BlogCategoryModel
-@{
- //page title
- ViewBag.Title = Loc["Admin.Content.Blog.BlogCategory.EditBlogCategoryDetails"];
-}
-
-<form asp-area="@Constants.AreaStore" asp-controller="Blog" asp-action="CategoryEdit" method="post" id="category-form">
-
- <div class="row">
- <div class="col-md-12">
- <div class="x_panel light form-fit">
- <div class="x_title">
- <div class="caption">
- <i class="fa fa-comment"></i>
- @Loc["Admin.Content.Blog.BlogCategory.EditBlogCategoryDetails"]
- <small>
- <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Content.Blog.BlogCategory.BackToList"], "CategoryList")
- </small>
- </div>
- <div class="actions">
- <div class="btn-group btn-group-devided">
- <button class="btn btn-success" type="submit" name="save">
- <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]
- </button>
- <button class="btn btn-success" type="submit" name="save-continue">
- <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]
- </button>
- <span id="blogcategory-delete" class="btn red">
- <i class="fa fa-trash-o"></i> @Loc["Admin.Common.Delete"]
- </span>
- </div>
- </div>
- </div>
- <vc:admin-widget widget-zone="blog_category_buttons" additional-data="Model"/>
- <div class="x_content form">
- <partial name="Partials/CreateOrUpdateCategory" model="Model"/>
- </div>
- </div>
- </div>
- </div>
-</form>
-<admin-delete-confirmation button-id="blogcategory-delete" action-name="CategoryDelete"/>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Comments.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Comments.cshtml
deleted file mode 100644
index 6a3b380f9..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Comments.cshtml
+++ /dev/null
@@ -1,114 +0,0 @@
-@using Grand.Web.Store.Models.Blogs
-@model BlogCommentListModel
-@inject AdminAreaSettings adminAreaSettings
-@{
- //page title
- ViewBag.Title = Loc["Admin.Content.Blog.Comments"];
- var filterByBlogPostId = Model.FilterByBlogPostId;
-}
-
-<div class="row">
- <div class="col-md-12">
- <div class="x_panel light form-fit">
- <div class="x_title">
- <div class="caption level-caption">
- <i class="fa fa-comment"></i>
- @Loc["Admin.Content.Blog.Comments"]
- </div>
- </div>
- <div class="x_content form">
- <div class="form-horizontal">
- <div class="form-body">
- <div class="x_content">
- <div id="comments-grid"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-</div>
-
-@{
- var readUrl = !string.IsNullOrEmpty(filterByBlogPostId) ? Url.Action("Comments", "Blog", new { filterByBlogPostId, area = Constants.AreaStore }) : Url.Action("Comments", "Blog", new { area = Constants.AreaStore });
-}
-<script>
- $(document).ready(function () {
- $("#comments-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@readUrl",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- destroy: {
- url: "@Html.Raw(Url.Action("CommentDelete", "Blog", new { area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors",
- model: {
- id: "Id",
- fields: {
- //do not implicitly specify all fields
- //we do it only for fields which implicitly require it
- //otherwise, they'll be formatted wrong way
- CreatedOn: {type: "date" }
- }
- }
- },
- error: function(e) {
- display_kendoui_grid_error(e);
- // Cancel the changes
- this.cancelChanges();
- },
- pageSize: @(adminAreaSettings.DefaultGridPageSize),
- serverPaging: true,
- serverFiltering: true,
- serverSorting: true
- },
- pageable: {
- refresh: true,
- pageSizes: [@(adminAreaSettings.GridPageSizes)]
- },
- editable: {
- confirmation: true,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "BlogPostTitle",
- title: "@Loc["Admin.Content.Blog.Comments.Fields.BlogPost"]",
- width: 200,
- encoded: false,
- template: '<a class="k-link" href="@Url.Action("Edit", "Blog", new { area = Constants.AreaStore })/#=BlogPostId#">#:kendo.htmlEncode(BlogPostTitle)#</a>'
- }, {
- field: "CustomerId",
- title: "@Loc["Admin.Content.Blog.Comments.Fields.Customer"]",
- width: 200,
- template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area = Constants.AreaStore })/#=CustomerId#">#:kendo.htmlEncode(CustomerInfo)#</a>'
- }, {
- field: "Comment",
- title: "@Loc["Admin.Content.Blog.Comments.Fields.Comment"]",
- encoded: false
- }, {
- field: "CreatedOn",
- title: "@Loc["Admin.Content.Blog.Comments.Fields.CreatedOn"]",
- width: 200,
- type: "date",
- format: "{0:G}"
- }, {
- command: { name: "destroy", text: "@Loc["Admin.Common.Delete"]" },
- title: "@Loc["Admin.Common.Delete"]",
- width: 100
- }]
- });
- });
-</script>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Create.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Create.cshtml
deleted file mode 100644
index c37419ab5..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Create.cshtml
+++ /dev/null
@@ -1,37 +0,0 @@
-@model BlogPostModel
-@{
- //page title
- ViewBag.Title = Loc["Admin.Content.Blog.BlogPosts.AddNew"];
-}
-<form asp-area="@Constants.AreaStore" asp-controller="Blog" asp-action="Create" method="post">
-
- <div class="row">
- <div class="col-md-12">
- <div class="x_panel light form-fit">
- <div class="x_title">
- <div class="caption">
- <i class="fa fa-comment"></i>
- @Loc["Admin.Content.Blog.BlogPosts.AddNew"]
- <small>
- <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Content.Blog.BlogPosts.BackToList"], "List")
- </small>
- </div>
- <div class="actions">
- <div class="btn-group btn-group-devided">
- <button class="btn btn-success" type="submit" name="save">
- <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]
- </button>
- <button class="btn btn-success" type="submit" name="save-continue">
- <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]
- </button>
- </div>
- </div>
- </div>
- <vc:admin-widget widget-zone="blog_details_buttons" additional-data="null"/>
- <div class="x_content form">
- <partial name="Partials/CreateOrUpdate" model="Model"/>
- </div>
- </div>
- </div>
- </div>
-</form>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabComments.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabComments.cshtml
deleted file mode 100644
index 1604773de..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabComments.cshtml
+++ /dev/null
@@ -1,93 +0,0 @@
-@model BlogPostModel
-@inject AdminAreaSettings adminAreaSettings
-@if (!string.IsNullOrEmpty(Model.Id))
-{
- <div class="panel panel-default">
- <vc:admin-widget widget-zone="blog_details_comments_top" additional-data="Model"/>
- <div class="panel-body">
- <div id="comments-grid"></div>
- </div>
- <vc:admin-widget widget-zone="blog_details_comments_bottom" additional-data="Model"/>
- </div>
-
- <script>
- $(document).ready(function () {
- $("#comments-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Url.Action("Comments", "Blog", new { filterByBlogPostId = Model.Id, area = Constants.AreaStore })",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- destroy: {
- url: "@Html.Raw(Url.Action("CommentDelete", "Blog", new { area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors",
- model: {
- id: "Id",
- fields: {
- //do not implicitly specify all fields
- //we do it only for fields which implicitly require it
- //otherwise, they'll be formatted wrong way
- CreatedOn: {type: "date" }
- }
- }
- },
- error: function(e) {
- display_kendoui_grid_error(e);
- // Cancel the changes
- this.cancelChanges();
- },
- pageSize: @(adminAreaSettings.DefaultGridPageSize),
- serverPaging: true,
- serverFiltering: true,
- serverSorting: true
- },
- pageable: {
- refresh: true,
- pageSizes: [@(adminAreaSettings.GridPageSizes)]
- },
- editable: {
- confirmation: true,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "CustomerId",
- title: "@Loc["Admin.Content.Blog.Comments.Fields.Customer"]",
- width: 200,
- template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area = Constants.AreaStore })/#=CustomerId#">#:kendo.htmlEncode(CustomerInfo)#</a>'
- }, {
- field: "Comment",
- title: "@Loc["Admin.Content.Blog.Comments.Fields.Comment"]",
- encoded: false
- }, {
- field: "CreatedOn",
- title: "@Loc["Admin.Content.Blog.Comments.Fields.CreatedOn"]",
- width: 200,
- type: "date",
- format: "{0:G}"
- }, {
- command: { name: "destroy", text: "@Loc["Admin.Common.Delete"]" },
- title: "@Loc["Admin.Common.Delete"]",
- width: 100
- }]
- });
- });
- </script>
-}
-else
-{
- <div class="note note-info">
- @Loc["Admin.Content.Blog.BlogPosts.SaveBeforeEdit"]
- </div>
-}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabInfo.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabInfo.cshtml
deleted file mode 100644
index 2a8f9bf11..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabInfo.cshtml
+++ /dev/null
@@ -1,170 +0,0 @@
-@using System.Text.Encodings.Web
-@using Microsoft.AspNetCore.Mvc.Razor
-@model BlogPostModel
-@inject IBlogService blogService
-
-<script>
- @{
- var blogTags = await blogService.GetAllBlogPostTags("", true);
- var blogTagsSb = new StringBuilder();
- blogTagsSb.Append("var initialBlogTags = [");
- for (var i = 0; i < blogTags.Count; i++)
- {
- var tag = blogTags[i];
- blogTagsSb.Append("'");
- blogTagsSb.Append(JavaScriptEncoder.Default.Encode(string.IsNullOrEmpty(tag.Name) ? "" : tag.Name));
- blogTagsSb.Append("'");
- if (i != blogTags.Count - 1)
- {
- blogTagsSb.Append(",");
- }
- }
-
- blogTagsSb.Append("]");
- }
-
- //tags
- $(document).ready(function () {
- @Html.Raw(blogTagsSb.ToString())
- $("#@Html.IdFor(model => model.Tags)").tagEditor({
- autocomplete: {
- delay: 0,
- position: { collision: 'flip' },
- source: initialBlogTags
- },
- delimiter: ',',
- placeholder: '@Loc["Admin.Content.Blog.BlogPosts.Fields.Tags.Placeholder"]'
- });
- });
-</script>
-
-@{
- Func<int, HelperResult>
- template = @<div class="form-body">
- <div class="form-group">
- <admin-label asp-for="@Model.Locales[item].Title"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="@Model.Locales[item].Title"/>
- <span asp-validation-for="@Model.Locales[item].Title"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="@Model.Locales[item].BodyOverview"/>
- <div class="col-md-9 col-sm-9">
- <admin-textarea asp-for="@Model.Locales[item].BodyOverview"></admin-textarea>
- <span asp-validation-for="@Model.Locales[item].BodyOverview"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="Locales[item].Body"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="@Model.Locales[item].Body" asp-template="Editor"/>
- <span asp-validation-for="Locales[item].Body"></span>
- </div>
- </div>
- <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/>
- </div>;
-}
-
-<div class="form-horizontal">
- <vc:admin-widget widget-zone="blog_details_info_top" additional-data="Model"/>
- <localized-editor localized-template="@template" name="blogpost-info-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">
- <div class="form-body">
- <div class="form-group">
- <admin-label asp-for="Title"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="Title"/>
- <span asp-validation-for="Title"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="BodyOverview"/>
- <div class="col-md-9 col-sm-9">
- <admin-textarea asp-for="BodyOverview"></admin-textarea>
- <span asp-validation-for="BodyOverview"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="Body"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="Body" asp-template="Editor"/>
- <span asp-validation-for="Body"></span>
- </div>
- </div>
- </div>
- </localized-editor>
- <div class="form-group">
- @{
- ViewData["Reference"] = "Blog";
- ViewData["ObjectId"] = Model.Id;
- }
- <admin-label asp-for="PictureId"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="PictureId"/>
- <span asp-validation-for="PictureId"></span>
- @if (!string.IsNullOrEmpty(Model.PictureId))
- {
- <label class="control-label">
- <a class='k-link picturelink' href='@Url.Action("PicturePopup", "Blog", new { area = Constants.AreaStore })/?blogpostId=@(Model.Id)'>@Loc["Admin.Common.Picture.Attributes"]</a>
- </label>
- <script>
- $(document).ready(function () {
- $('.picturelink').magnificPopup({
- type: 'ajax',
- settings: { cache: false, async: false },
- midClick: true,
- callbacks:
- {
- parseAjax: function (mfpResponse) {
- mfpResponse.data = $('<div></div>').html(mfpResponse.data);
- },
- ajaxContentAdded: function () {
- $('.mfp-wrap').removeAttr('tabindex');
- }
- }
- });
- });
- </script>
- }
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="AllowComments"/>
- <div class="col-md-9 col-sm-9">
- <label class="mt-checkbox mt-checkbox-outline control control-checkbox">
- <admin-input asp-for="AllowComments"/>
- <div class="control__indicator"></div>
- </label>
- <span asp-validation-for="AllowComments"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="Tags"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="Tags"/>
- <span asp-validation-for="Tags"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="CreateDate"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="CreateDate"/>
- <span asp-validation-for="CreateDate"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="StartDate"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="StartDate"/>
- <span asp-validation-for="StartDate"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="EndDate"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="EndDate"/>
- <span asp-validation-for="EndDate"></span>
- </div>
- </div>
- <vc:admin-widget widget-zone="blog_details_info_bottom" additional-data="Model"/>
-</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabProducts.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabProducts.cshtml
deleted file mode 100644
index cf5cb85cb..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabProducts.cshtml
+++ /dev/null
@@ -1,128 +0,0 @@
-@model BlogPostModel
-@inject AdminAreaSettings adminAreaSettings
-@if (!string.IsNullOrEmpty(Model.Id))
-{
- <div class="panel panel-default">
- <vc:admin-widget widget-zone="blog_details_product_top" additional-data="Model"/>
- <div class="panel-body">
- <div id="product-grid"></div>
- </div>
- <div class="panel-footer">
- <a id="btnAddNewProduct" href="@(Url.Action("ProductAddPopup", "Blog", new { blogPostId = Model.Id, btnId = "btnRefreshProducts", formId = "blog-edit", area = Constants.AreaStore }))" class="k-button"><i class="fa fa-plus"></i>&nbsp;@Loc["Admin.Content.Blog.BlogPosts.Products.AddNew"]</a>
- <input type="button" id="btnRefreshProducts" style="display: none"/>
- </div>
- <vc:admin-widget widget-zone="blog_details_product_bottom" additional-data="Model"/>
- </div>
- <script>
- $(document).ready(function () {
- $('#btnAddNewProduct').magnificPopup({
- type: 'ajax',
- settings: { cache: false, async: false },
- midClick: true,
- callbacks: {
- parseAjax: function (mfpResponse) {
- mfpResponse.data = $('<div></div>').html(mfpResponse.data);
- },
- ajaxContentAdded: function () {
- $('.mfp-wrap').removeAttr('tabindex');
- }
- }
- });
- $("#product-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("Products", "Blog", new { blogPostId = Model.Id, area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- update: {
- url:"@Html.Raw(Url.Action("UpdateProduct", "Blog", new { blogPostId = Model.Id, area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- destroy: {
- url: "@Html.Raw(Url.Action("DeleteProduct", "Blog", new { area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors",
- model: {
- id: "Id",
- fields: {
- ProductName: {editable: false, type: "string" },
- DisplayOrder: {editable: true, type: "number", format:"{0:n2}" },
- }
- }
- },
- error: function(e) {
- display_kendoui_grid_error(e);
- // Cancel the changes
- this.cancelChanges();
- },
- pageSize: @(adminAreaSettings.DefaultGridPageSize),
- serverPaging: true,
- serverFiltering: true,
- serverSorting: true
- },
- pageable: {
- refresh: true,
- pageSizes: [@(adminAreaSettings.GridPageSizes)]
- },
- editable: {
- confirmation: false,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "ProductName",
- title: "@Loc["Admin.Content.Blog.Product.Fields.ProductName"]",
- width: 300,
- template: '<a href="@Url.Action("Edit", "Product", new { area = Constants.AreaStore })/#=ProductId#" target="_blank">#=kendo.htmlEncode(ProductName)#</a>'
- }, {
- field: "DisplayOrder",
- title: "@Loc["Admin.Content.Blog.Product.Fields.DisplayOrder"]",
- width: 100,
- type: "number",
-
- }, {
- command: [{
- name: "edit",
- text: {
- edit: "@Loc["Admin.Common.Edit"]",
- update: "@Loc["Admin.Common.Update"]",
- cancel: "@Loc["Admin.Common.Cancel"]"} }, {
- name: "destroy",
- text: "@Loc["Admin.Common.Delete"]"
- }],
- width: 200
- }]
- });
- });
- </script>
- <script>
- $(document).ready(function () {
- $('#btnRefreshProducts').click(function () {
- //refresh grid
- var grid = $("#product-grid").data('kendoGrid');
- grid.dataSource.read();
-
- //return false to don't reload a page
- return false;
- });
- });
- </script>
-}
-else
-{
- <div class="note note-info">
- @Loc["Admin.Content.Blog.BlogPosts.SaveBeforeEdit"]
- </div>
-}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabSeo.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabSeo.cshtml
deleted file mode 100644
index 1fef5cb5b..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.TabSeo.cshtml
+++ /dev/null
@@ -1,75 +0,0 @@
-@using Microsoft.AspNetCore.Mvc.Razor
-@model BlogPostModel
-
-<vc:admin-widget widget-zone="blog_details_seo_top" additional-data="Model"/>
-@{
- Func<int, HelperResult>
- template = @<div class="form-body">
- <div class="form-group">
- <admin-label asp-for="@Model.Locales[item].MetaKeywords"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="@Model.Locales[item].MetaKeywords"/>
- <span asp-validation-for="@Model.Locales[item].MetaKeywords"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="@Model.Locales[item].MetaDescription"/>
- <div class="col-md-9 col-sm-9">
- <admin-textarea asp-for="@Model.Locales[item].MetaDescription"></admin-textarea>
- <span asp-validation-for="@Model.Locales[item].MetaDescription"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="@Model.Locales[item].MetaTitle"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="@Model.Locales[item].MetaTitle"/>
- <span asp-validation-for="@Model.Locales[item].MetaTitle"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="@Model.Locales[item].SeName"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="@Model.Locales[item].SeName"/>
- <span asp-validation-for="@Model.Locales[item].SeName"></span>
- </div>
- </div>
- <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/>
- </div>;
-}
-
-<div class="form-horizontal">
- <localized-editor localized-template="@template" name="blogpost-seo-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">
- <div class="form-body">
- <div class="form-group">
- <admin-label asp-for="MetaKeywords"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="MetaKeywords"/>
- <span asp-validation-for="MetaKeywords"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="MetaDescription"/>
- <div class="col-md-9 col-sm-9">
- <admin-textarea asp-for="MetaDescription"></admin-textarea>
- <span asp-validation-for="MetaDescription"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="MetaTitle"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="MetaTitle"/>
- <span asp-validation-for="MetaTitle"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="SeName"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="SeName"/>
- <span asp-validation-for="SeName"></span>
- </div>
- </div>
- </div>
- </localized-editor>
-</div>
-
-<vc:admin-widget widget-zone="blog_details_seo_bottom" additional-data="Model"/>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.cshtml
deleted file mode 100644
index 734865b7e..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdate.cshtml
+++ /dev/null
@@ -1,50 +0,0 @@
-@model BlogPostModel
-
-<div asp-validation-summary="All"></div>
-<input asp-for="Id" type="hidden"/>
-<input id="active-menu-item" type="hidden" value="/@Constants.AreaStore/Blog/List"/>
-
-<admin-tabstrip name="blog-post-edit">
- <items>
- <tabstrip-item text="@Loc["Admin.Content.Blog.BlogPosts.Info"]" tab-index="0">
- <content>
- <div>
- <partial name="Partials/CreateOrUpdate.TabInfo" model="Model"/>
- </div>
- </content>
- </tabstrip-item>
- <tabstrip-item text="@Loc["Admin.Common.SEO"]" tab-index="1">
- <content>
- <div>
- <partial name="Partials/CreateOrUpdate.TabSeo" model="Model"/>
- </div>
- </content>
- </tabstrip-item>
- <tabstrip-item text="@Loc["Admin.Content.Blog.BlogPosts.Products"]" tab-index="2">
- <content>
- <div>
- <partial name="Partials/CreateOrUpdate.TabProducts" model="Model"/>
- </div>
- </content>
- </tabstrip-item>
- <tabstrip-item text="@Loc["Admin.Content.Blog.BlogPosts.Comments"]" tab-index="3">
- <content>
- <div>
- <partial name="Partials/CreateOrUpdate.TabComments" model="Model"/>
- </div>
- </content>
- </tabstrip-item>
- <tabstrip-item text="@Loc["Admin.Common.UserFields.Tab"]" tab-index="4">
- <content>
- <div>
- <partial name="Partials/UserFields" model="Model"/>
- </div>
- </content>
- </tabstrip-item>
- <vc:admin-widget widget-zone="blog_details_tabs" additional-data="Model"/>
- </items>
-</admin-tabstrip>
-
-<link rel="stylesheet" type="text/css" asp-src="@(Grand.SharedUIResources.Constants.WwwRoot)/administration/tagEditor/jquery.tag-editor.css"/>
-<script asp-location="Footer" asp-src="@(Grand.SharedUIResources.Constants.WwwRoot)/administration/tagEditor/jquery.tag-editor.min.js"></script>
-<script asp-location="Footer" asp-src="@(Grand.SharedUIResources.Constants.WwwRoot)/administration/tagEditor/jquery.caret.min.js"></script>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdateCategory.Posts.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdateCategory.Posts.cshtml
deleted file mode 100644
index 181e70aeb..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdateCategory.Posts.cshtml
+++ /dev/null
@@ -1,112 +0,0 @@
-@model BlogCategoryModel
-
-@inject AdminAreaSettings adminAreaSettings
-@if (!string.IsNullOrEmpty(Model.Id))
-{
- <div class="panel panel-default">
- <div class="panel-body">
- <div id="posts-grid"></div>
- </div>
- <div class="panel-footer">
- <a id="btnAddNewPost" href="@(Url.Action("BlogPostAddPopup", "Blog", new { categoryId = Model.Id, btnId = "btnRefreshPosts", formId = "category-form", area = Constants.AreaStore }))" class="k-button"><i class="fa fa-plus"></i>&nbsp;@Loc["Admin.Content.Blog.BlogCategory.AddNewPost"]</a>
- <input type="submit" id="btnRefreshPosts" style="display: none"/>
- </div>
- </div>
- <script>
- $(document).ready(function () {
- $('#btnAddNewPost').magnificPopup({
- type: 'ajax',
- settings: { cache: false, async: false },
- midClick: true,
- callbacks: {
- parseAjax: function (mfpResponse) {
- mfpResponse.data = $('<div></div>').html(mfpResponse.data);
- },
- ajaxContentAdded: function () {
- $('.mfp-wrap').removeAttr('tabindex');
- }
- }
- });
- $("#posts-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("CategoryPostList", "Blog", new { categoryId = Model.Id, area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- destroy: {
- url: "@Html.Raw(Url.Action("CategoryPostDelete", "Blog", new { categoryId = Model.Id, area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors",
- model: {
- id: "Id",
- fields: {
- Name: {editable: false, type: "string" },
- BlogPostId: {editable: false, type: "string" }
- }
- }
- },
- requestEnd: function(e) {
- if(e.type=="update") {
- this.read();
- }
- },
- error: function(e) {
- display_kendoui_grid_error(e);
- // Cancel the changes
- this.cancelChanges();
- },
- pageSize: @(adminAreaSettings.DefaultGridPageSize),
- serverPaging: true,
- serverFiltering: true,
- serverSorting: true
- },
- pageable: {
- refresh: true,
- pageSizes: [@(adminAreaSettings.GridPageSizes)]
- },
- editable: {
- confirmation: false,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "Name",
- title: "@Loc["Admin.Content.Blog.BlogCategory.Fields.Post"]",
- template: '<a class="k-link" href="@Url.Action("Edit", "Blog", new { area = Constants.AreaStore })/#=BlogPostId#">#=kendo.htmlEncode(Name)#</a>',
- },{
- command: [{
- name: "destroy",
- text: "@Loc["Admin.Common.Delete"]"
- }],
- }]
- });
- });
- </script>
- <script>
- $(document).ready(function () {
- $('#btnRefreshPosts').click(function () {
- //refresh grid
- var grid = $("#posts-grid").data('kendoGrid');
- grid.dataSource.read();
- //return false to don't reload a page
- return false;
- });
- });
- </script>
-}
-else
-{
- <div class="note note-info">
- @Loc["Admin.Content.Blog.BlogCategory.SaveBeforeEdit"]
- </div>
-}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdateCategory.TabInfo.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdateCategory.TabInfo.cshtml
deleted file mode 100644
index 31a0a955c..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/CreateOrUpdateCategory.TabInfo.cshtml
+++ /dev/null
@@ -1,47 +0,0 @@
-@using Microsoft.AspNetCore.Mvc.Razor
-@model BlogCategoryModel
-
-
-@{
- Func<int, HelperResult>
- template = @<div class="form-body">
- <div class="form-group">
- <admin-label asp-for="@Model.Locales[item].Name"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="@Model.Locales[item].Name"/>
- <span asp-validation-for="@Model.Locales[item].Name"></span>
- </div>
- </div>
- <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/>
- </div>;
-}
-
-<div class="form-horizontal">
- <vc:admin-widget widget-zone="blog_category_info_top" additional-data="Model"/>
- <localized-editor localized-template="@template" name="blogcategory-info-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">
- <div class="form-body">
- <div class="form-group">
- <admin-label asp-for="Name"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="Name"/>
- <span asp-validation-for="Name"></span>
- </div>
- </div>
- </div>
- </localized-editor>
- <div class="form-group">
- <admin-label asp-for="SeName"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="SeName"/>
- <span asp-validation-for="SeName"></span>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="DisplayOrder"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="DisplayOrder"/>
- <span asp-validation-for="DisplayOrder"></span>
- </div>
- </div>
- <vc:admin-widget widget-zone="blog_category_info_bottom" additional-data="Model"/>
-</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryButtons.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryButtons.cshtml
new file mode 100644
index 000000000..be5338280
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryButtons.cshtml
@@ -0,0 +1,2 @@
+@model dynamic
+<vc:store-widget widget-zone="store_blog_category_buttons" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryButtonsCreate.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryButtonsCreate.cshtml
new file mode 100644
index 000000000..afe39479f
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryButtonsCreate.cshtml
@@ -0,0 +1,2 @@
+@model dynamic
+<vc:store-widget widget-zone="store_blog_category_buttons" additional-data="null"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryInfo.Bottom.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryInfo.Bottom.cshtml
new file mode 100644
index 000000000..0a45f79be
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryInfo.Bottom.cshtml
@@ -0,0 +1,2 @@
+@model BlogCategoryModel
+<vc:store-widget widget-zone="store_blog_category_info_bottom" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryInfo.Top.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryInfo.Top.cshtml
new file mode 100644
index 000000000..acc263f38
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryInfo.Top.cshtml
@@ -0,0 +1,2 @@
+@model BlogCategoryModel
+<vc:store-widget widget-zone="store_blog_category_info_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryTabs.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryTabs.cshtml
new file mode 100644
index 000000000..efba5aa9a
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.CategoryTabs.cshtml
@@ -0,0 +1,2 @@
+@model BlogCategoryModel
+<vc:store-widget widget-zone="store_blog_category_details_tabs" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Comments.Bottom.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Comments.Bottom.cshtml
new file mode 100644
index 000000000..54f4fdce5
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Comments.Bottom.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:store-widget widget-zone="store_blog_details_comments_bottom" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Comments.Top.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Comments.Top.cshtml
new file mode 100644
index 000000000..a839ec9fe
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Comments.Top.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:store-widget widget-zone="store_blog_details_comments_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.DetailsButtons.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.DetailsButtons.cshtml
new file mode 100644
index 000000000..44e6dcd02
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.DetailsButtons.cshtml
@@ -0,0 +1,2 @@
+@model dynamic
+<vc:store-widget widget-zone="store_blog_details_buttons" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.DetailsButtonsCreate.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.DetailsButtonsCreate.cshtml
new file mode 100644
index 000000000..6dd439139
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.DetailsButtonsCreate.cshtml
@@ -0,0 +1,2 @@
+@model dynamic
+<vc:store-widget widget-zone="store_blog_details_buttons" additional-data="null"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Info.Bottom.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Info.Bottom.cshtml
new file mode 100644
index 000000000..d2163b72b
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Info.Bottom.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:store-widget widget-zone="store_blog_details_info_bottom" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Info.Top.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Info.Top.cshtml
new file mode 100644
index 000000000..8b7f1fe54
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Info.Top.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:store-widget widget-zone="store_blog_details_info_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Products.Bottom.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Products.Bottom.cshtml
new file mode 100644
index 000000000..cf4c50d5c
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Products.Bottom.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:store-widget widget-zone="store_blog_details_product_bottom" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Products.Top.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Products.Top.cshtml
new file mode 100644
index 000000000..b57377326
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Products.Top.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:store-widget widget-zone="store_blog_details_product_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.SEO.Bottom.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.SEO.Bottom.cshtml
new file mode 100644
index 000000000..df6b96a21
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.SEO.Bottom.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:store-widget widget-zone="store_blog_details_seo_bottom" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.SEO.Top.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.SEO.Top.cshtml
new file mode 100644
index 000000000..bd28e7b5f
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.SEO.Top.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:store-widget widget-zone="store_blog_details_seo_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Tabs.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Tabs.cshtml
new file mode 100644
index 000000000..70ce1e4dd
--- /dev/null
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/Partials/WidgetZone.Tabs.cshtml
@@ -0,0 +1,2 @@
+@model BlogPostModel
+<vc:store-widget widget-zone="store_blog_details_tabs" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/ProductAddPopup.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/ProductAddPopup.cshtml
deleted file mode 100644
index d161932ad..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Blog/ProductAddPopup.cshtml
+++ /dev/null
@@ -1,221 +0,0 @@
-@model BlogProductModel.AddProductModel
-@inject AdminAreaSettings adminAreaSettings
-@{
- Layout = "";
- //page title
- ViewBag.Title = Loc["Admin.Content.Blog.BlogPosts.Products.AddNew"];
-}
-
-<form id="ProductAddPopup" asp-area="@Constants.AreaStore" asp-controller="Blog" asp-action="ProductAddPopup" method="post"
- asp-route-BlogPostId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["BlogPostId"])"
- asp-route-btnId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["btnId"])"
- asp-route-formId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["formId"])">
-
- <div class="row">
- <div class="col-md-12">
- <div class="x_panel light form-fit popup-window">
- <div class="x_title">
- <div class="caption">
- <i class="fa fa-sitemap"></i>
- @Loc["Admin.Content.Blog.BlogPosts.Products.AddNew"]
- </div>
- </div>
- <div class="x_content form">
- <div class="form-horizontal">
- <div class="form-body">
- <div class="main-header col-12 px-0">
- <div class="row align-items-end">
- <div class="col-md col-ms-12 col-12">
- <div class="form-group mb-0">
- <admin-label asp-for="SearchProductName" class="control-label"/>
- <admin-input asp-for="SearchProductName"/>
- </div>
- </div>
- <div class="col-md-auto col-sm-12 col-12">
- <div class="form-actions">
- <div class="btn-group btn-group-devided">
- <button class="btn btn-success filter-submit" id="search-products">
- <i class="fa fa-search"></i>&nbsp; @Loc["Admin.Common.Search"]
- </button>
- <button class="btn btn-info" type="button" data-toggle="collapse" data-target="#filterCollapse" aria-expanded="false" aria-controls="filterCollapse">
- <i class="fa fa-filter"></i>&nbsp; @Loc["Admin.Common.Filters"]
- </button>
- </div>
- <button class="btn btn-success" type="submit" name="save"><i class="fa fa-check"></i> &nbsp; @Loc["Admin.Common.Save"] </button>
- </div>
- </div>
- </div>
- </div>
- <div class="collapse" id="filterCollapse">
- <div class="drop-filters-container">
- <div class="form-group">
- <admin-label asp-for="SearchCategoryId" class="col-sm-3 control-label"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="SearchCategoryId"/>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="SearchCollectionId" class="col-sm-3 control-label"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="SearchCollectionId"/>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="SearchBrandId" class="col-sm-3 control-label"/>
- <div class="col-md-9 col-sm-9">
- <admin-input asp-for="SearchBrandId"/>
- </div>
- </div>
- <div class="form-group">
- <admin-label asp-for="SearchProductTypeId" class="col-sm-3 control-label"/>
- <div class="col-md-9 col-sm-9">
- <admin-select asp-for="SearchProductTypeId" asp-items="Model.AvailableProductTypes"/>
- </div>
- </div>
- </div>
- </div>
- <div id="products-grid"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <script>
- var mfp = $.magnificPopup.instance;
- $("#ProductAddPopup").submit(function (e) {
- e.preventDefault();
- var form = $(this);
- var url = form.attr('action');
- $.ajax({
- type: "POST",
- url: url,
- data: form.serialize(),
- success: function (data) {
- if (data == "") {
- mfp.close();
- $('#btnRefreshProducts').click();
- } else {
- $.magnificPopup.open({
- items: {
- src: data,
- type: 'inline'
- },
- callbacks: {
- open: function () {
- $('.mfp-wrap').removeAttr('tabindex');
- }
- }
- });
- }
- }
- });
- });
-
- $('.extend-collapse').hide();
- $('.filter-extend-button').click(function () {
- $('.extend-collapse').toggle("slow");
- $('.filter-text-close').toggle();
- });
-
- $("#products-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("ProductAddPopupList", "Blog", new { area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: additionalData
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors"
- },
- error: function(e) {
- display_kendoui_grid_error(e);
- // Cancel the changes
- this.cancelChanges();
- },
- pageSize: @(adminAreaSettings.DefaultGridPageSize),
- serverPaging: true,
- serverFiltering: true,
- serverSorting: true
- },
- pageable: {
- refresh: true,
- pageSizes: [@(adminAreaSettings.GridPageSizes)]
- },
- editable: {
- confirmation: false,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "Id",
- title: "@Loc["Admin.Common.Check"]",
- headerTemplate: "<input id='mastercheckbox' type='checkbox'/>",
- headerAttributes: { style: "text-align:center" },
- template: "<input type='checkbox' name='SelectedProductIds' value='#=Id#' class='checkboxGroups' />",
- attributes: { style: "text-align:center" },
- width: 50
- }, {
- field: "Name",
- title: "@Loc["Admin.Catalog.Products.Fields.Name"]"
- }, {
- field: "Published",
- title: "@Loc["Admin.Catalog.Products.Fields.Published"]",
- width: 100,
- headerAttributes: { style: "text-align:center" },
- attributes: { style: "text-align:center" },
- template: '# if(Published) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
- }]
- });
-
- $('#search-products').click(function() {
- var grid = $('#products-grid').data('kendoGrid');
- grid.dataSource.page(1); //new search. Set page size to 1
- //grid.dataSource.read(); we already loaded the grid above using "page" function
- //clear selected checkboxes
- $('.checkboxGroups').prop('checked', false).change();
- return false;
- });
-
- $("#@Html.IdFor(model => model.SearchProductName)").keydown(function(event) {
- if (event.keyCode == 13) {
- $("#search-products").click();
- return false;
- }
- });
-
- //wire up checkboxes
- $('#mastercheckbox').click(function() {
- $('.checkboxGroups').prop('checked', $(this).is(':checked')).change();
- });
-
- $('#products-grid').on('change', 'input[type=checkbox][id!=mastercheckbox]', function(e) {
- updateMasterCheckbox();
- });
-
- function additionalData() {
- var data = {
- SearchProductName: $('#@Html.IdFor(model => model.SearchProductName)').val(),
- SearchCategoryId: $('#SearchCategoryId').val(),
- SearchBrandId: $('#SearchBrandId').val(),
- SearchCollectionId: $('#SearchCollectionId').val(),
- SearchProductTypeId: $('#SearchProductTypeId').val()
- };
- addAntiForgeryToken(data);
- return data;
- }
-
- function updateMasterCheckbox() {
- var numChkBoxes = $('#products-grid input[type=checkbox][id!=mastercheckbox]').length;
- var numChkBoxesChecked = $('#products-grid input[type=checkbox][id!=mastercheckbox]:checked').length;
- $('#mastercheckbox').prop('checked', numChkBoxes == numChkBoxesChecked && numChkBoxes > 0);
- }
-
- </script>
-</form>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Store/Controllers/BlogController.cs b/src/Web/Grand.Web.Store/Controllers/BlogController.cs
index ec2886c66..368dbb8cf 100644
--- a/src/Web/Grand.Web.Store/Controllers/BlogController.cs
+++ b/src/Web/Grand.Web.Store/Controllers/BlogController.cs
@@ -2,711 +2,66 @@ using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Business.Core.Interfaces.Common.Stores;
using Grand.Domain.Blogs;
using Grand.Domain.Permissions;
using Grand.Domain.Seo;
-using Grand.Infrastructure;
-using Grand.Web.AdminShared.Extensions;
+using Grand.Web.AdminShared.Controllers;
using Grand.Web.AdminShared.Extensions.Mapping;
using Grand.Web.AdminShared.Interfaces;
-using Grand.Web.AdminShared.Models.Blogs;
-using Grand.Web.AdminShared.Models.Common;
-using Grand.Web.Common.DataSource;
using Grand.Web.Common.Filters;
+using Grand.Web.Common.Localization;
using Grand.Web.Common.Security.Authorization;
-using Grand.Web.Store.Models.Blogs;
+using Grand.Web.Store.Extensions;
using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Store.Controllers;
-[PermissionAuthorize(PermissionSystemName.Blog)]
-public class BlogController : BaseStoreController
+// Reduced to a thin subclass of BaseBlogController (ARCH-001 Blog consolidation). All regions of
+// behavior live in the shared base; this class only supplies Store's DI wiring, the
+// EditWarningCheck hook, the kept Preview action (Admin has no equivalent), and the attributes that
+// used to arrive transitively via BaseStoreController. Same pattern as CategoryController.
+[AutoValidateAntiforgeryToken]
+[Area(Constants.AreaStore)]
+[AuthorizeStore]
+[AuthorizeMenu]
+public class BlogController(
+ IBlogService blogService,
+ IBlogViewModelService blogViewModelService,
+ ILanguageService languageService,
+ ITranslationService translationService,
+ IStoreService storeService,
+ IDateTimeService dateTimeService,
+ IPictureViewModelService pictureViewModelService,
+ SeoSettings seoSettings,
+ IAdminDataScope<BlogPost> postScope,
+ IAdminDataScope<BlogCategory> categoryScope)
+ : BaseBlogController(blogService, blogViewModelService, languageService, translationService,
+ storeService, dateTimeService, pictureViewModelService, seoSettings, postScope, categoryScope)
{
- #region Constants
-
- private const string NoAccessToBlogPostMessage = "You don't have access to this blog post";
- private const string NoAccessToBlogCategoryMessage = "You don't have access to this blog category";
- private const string CategoryListAction = "CategoryList";
-
- #endregion
-
- #region Constructors
-
- public BlogController(
- IBlogService blogService,
- IBlogViewModelService blogViewModelService,
- ILanguageService languageService,
- ITranslationService translationService,
- IContextAccessor contextAccessor,
- IDateTimeService dateTimeService,
- IPictureViewModelService pictureViewModelService,
- SeoSettings seoSettings)
- {
- _blogService = blogService;
- _blogViewModelService = blogViewModelService;
- _languageService = languageService;
- _translationService = translationService;
- _contextAccessor = contextAccessor;
- _dateTimeService = dateTimeService;
- _pictureViewModelService = pictureViewModelService;
- _seoSettings = seoSettings;
- }
-
- #endregion
-
- #region Fields
-
- private readonly IBlogService _blogService;
- private readonly IBlogViewModelService _blogViewModelService;
- private readonly ILanguageService _languageService;
- private readonly ITranslationService _translationService;
- private readonly IContextAccessor _contextAccessor;
- private readonly IDateTimeService _dateTimeService;
- private readonly IPictureViewModelService _pictureViewModelService;
- private readonly SeoSettings _seoSettings;
- #endregion
-
- #region Blog posts
-
- public IActionResult Index()
- {
- return RedirectToAction("List");
- }
-
- public IActionResult List()
- {
- return View();
- }
-
- [PermissionAuthorizeAction(PermissionActionName.List)]
- [HttpPost]
- public async Task<IActionResult> List(DataSourceRequest command)
- {
- var blogPosts = await _blogViewModelService.PrepareBlogPostsModel(command.Page, command.PageSize);
- var gridModel = new DataSourceResult {
- Data = blogPosts.blogPosts,
- Total = blogPosts.totalCount
- };
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Create)]
- public async Task<IActionResult> Create()
- {
- var model = new BlogPostModel {
- //default values
- AllowComments = true,
- CreateDate = DateTime.UtcNow
- };
-
- //locales
- await AddLocales(_languageService, model.Locales);
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
- public async Task<IActionResult> Create(BlogPostModel model, bool continueEditing)
- {
- if (ModelState.IsValid)
- {
- model.Stores = [_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId];
- var blogPost = await _blogViewModelService.InsertBlogPostModel(model);
- Success(_translationService.GetResource("Admin.Content.Blog.BlogPosts.Added"));
- return continueEditing ? RedirectToAction("Edit", new { id = blogPost.Id }) : RedirectToAction("List");
- }
-
- //If we got this far, something failed, redisplay form
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Preview)]
- public async Task<IActionResult> Edit(string id)
- {
- var blogPost = await _blogService.GetBlogPostById(id);
- if (blogPost == null)
- //No blog post found with the specified id
- return RedirectToAction("List");
-
- if (!blogPost.LimitedToStores || (blogPost.LimitedToStores &&
- blogPost.Stores.Contains(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId) &&
- blogPost.Stores.Count > 1))
- {
- Warning(_translationService.GetResource("Admin.Content.Blog.BlogPosts.Permissions"));
- }
- else
- {
- if (!blogPost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return RedirectToAction("List");
- }
-
- var model = blogPost.ToModel(_dateTimeService);
-
- //locales
- await AddLocales(_languageService, model.Locales, (locale, languageId) =>
- {
- locale.Title = blogPost.GetTranslation(x => x.Title, languageId, false);
- locale.Body = blogPost.GetTranslation(x => x.Body, languageId, false);
- locale.BodyOverview = blogPost.GetTranslation(x => x.BodyOverview, languageId, false);
- locale.MetaKeywords = blogPost.GetTranslation(x => x.MetaKeywords, languageId, false);
- locale.MetaDescription = blogPost.GetTranslation(x => x.MetaDescription, languageId, false);
- locale.MetaTitle = blogPost.GetTranslation(x => x.MetaTitle, languageId, false);
- locale.SeName = blogPost.GetSeName(languageId, false);
- });
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
- public async Task<IActionResult> Edit(BlogPostModel model, bool continueEditing)
- {
- var blogPost = await _blogService.GetBlogPostById(model.Id);
- if (blogPost == null)
- //No blog post found with the specified id
- return RedirectToAction("List");
-
- if (!blogPost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return RedirectToAction("Edit", new { id = blogPost.Id });
-
- if (ModelState.IsValid)
- {
- model.Stores = [_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId];
- blogPost = await _blogViewModelService.UpdateBlogPostModel(model, blogPost);
- Success(_translationService.GetResource("Admin.Content.Blog.BlogPosts.Updated"));
-
- if (continueEditing)
- {
- //selected tab
- await SaveSelectedTabIndex();
- return RedirectToAction("Edit", new { id = blogPost.Id });
- }
- return RedirectToAction("List");
- }
-
- //If we got this far, something failed, redisplay form
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- [HttpPost]
- public async Task<IActionResult> Delete(string id)
+ // Re-derived from the original Store BlogController.Edit(GET) - the condition is unusual (warns
+ // when NOT limited to stores at all, or when limited AND the staff member's store is one of
+ // several) and easy to get backwards. Identical shape to CategoryController's own
+ // EditWarningCheck override - same underlying idiom, different entity.
+ protected override void EditWarningCheck(BlogPost blogPost)
{
- var blogPost = await _blogService.GetBlogPostById(id);
- if (blogPost == null)
- //No blog post found with the specified id
- return RedirectToAction("List");
-
- if (!blogPost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return RedirectToAction("Edit", new { id = blogPost.Id });
-
- if (ModelState.IsValid)
- {
- await _blogService.DeleteBlogPost(blogPost);
- Success(_translationService.GetResource("Admin.Content.Blog.BlogPosts.Deleted"));
- return RedirectToAction("List");
- }
-
- Error(ModelState);
- return RedirectToAction("Edit", new { id });
+ if (!blogPost.LimitedToStores ||
+ (blogPost.LimitedToStores &&
+ blogPost.Stores.Contains(PostScope.DefaultStoreId) &&
+ blogPost.Stores.Count > 1))
+ Warning(TranslationService.GetResource("Admin.Content.Blog.BlogPosts.Permissions"));
}
+ // Admin has no equivalent action - a genuine Store-only addition, kept on the concrete subclass
+ // rather than the shared base.
[PermissionAuthorizeAction(PermissionActionName.Preview)]
public async Task<IActionResult> Preview(string id)
{
- var blogPost = await _blogService.GetBlogPostById(id);
- if (blogPost == null)
- return RedirectToAction("List");
-
- if (!blogPost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return RedirectToAction("List");
-
- var model = blogPost.ToModel(_dateTimeService);
- return View(model);
- }
-
- #endregion
-
- #region Picture
-
- [PermissionAuthorizeAction(PermissionActionName.Preview)]
- public async Task<IActionResult> PicturePopup(string blogpostId)
- {
- var blogpost = await _blogService.GetBlogPostById(blogpostId);
- if (blogpost == null)
- return Content("Blog post not exist");
-
- if (!blogpost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return Content(NoAccessToBlogPostMessage);
-
- if (string.IsNullOrEmpty(blogpost.PictureId))
- return Content("Picture not exist");
-
- return View("Partials/PicturePopup",
- await _pictureViewModelService.PreparePictureModel(blogpost.PictureId, blogpost.Id));
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- public async Task<IActionResult> PicturePopup(PictureModel model)
- {
- if (ModelState.IsValid)
- {
- var blogpost = await _blogService.GetBlogPostById(model.ObjectId);
- if (blogpost == null)
- throw new ArgumentException("No blog post found with the specified id");
-
- if (!blogpost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return Content(NoAccessToBlogPostMessage);
-
- if (string.IsNullOrEmpty(blogpost.PictureId))
- throw new ArgumentException("No picture found with the specified id");
-
- if (blogpost.PictureId != model.Id)
- throw new ArgumentException("Picture ident doesn't fit with blog post");
-
- await _pictureViewModelService.UpdatePicture(model);
-
- return Content("");
- }
-
- Error(ModelState);
-
- return View("Partials/PicturePopup", model);
- }
-
- #endregion
-
- #region Comments
-
- public IActionResult Comments(string filterByBlogPostId)
- {
- var model = new BlogCommentListModel { FilterByBlogPostId = filterByBlogPostId };
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.List)]
- [HttpPost]
- public async Task<IActionResult> Comments(string filterByBlogPostId, DataSourceRequest command)
- {
- var model = await _blogViewModelService.PrepareBlogPostCommentsModel(filterByBlogPostId, command.Page,
- command.PageSize);
- var gridModel = new DataSourceResult {
- Data = model.blogComments,
- Total = model.totalCount
- };
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- public async Task<IActionResult> CommentDelete(string id)
- {
- var comment = await _blogService.GetBlogCommentById(id);
- if (comment == null)
- throw new ArgumentException("No comment found with the specified id");
-
- var blogPost = await _blogService.GetBlogPostById(comment.BlogPostId);
-
- if (!blogPost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return ErrorForKendoGridJson(NoAccessToBlogPostMessage);
-
- if (ModelState.IsValid)
- {
- await _blogService.DeleteBlogComment(comment);
- //update totals
- var comments = await _blogService.GetBlogCommentsByBlogPostId(blogPost.Id);
- blogPost.CommentCount = comments.Count;
- await _blogService.UpdateBlogPost(blogPost);
- return new JsonResult("");
- }
-
- return ErrorForKendoGridJson(ModelState);
- }
-
- #endregion
-
- #region Products
-
- [PermissionAuthorizeAction(PermissionActionName.List)]
- [HttpPost]
- public async Task<IActionResult> Products(string blogPostId, DataSourceRequest command)
- {
- var blogPost = await _blogService.GetBlogPostById(blogPostId);
-
- if (!blogPost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return ErrorForKendoGridJson(NoAccessToBlogPostMessage);
-
- var model = await _blogViewModelService.PrepareBlogProductsModel(blogPostId, command.Page, command.PageSize);
- var gridModel = new DataSourceResult {
- Data = model.blogProducts,
- Total = model.totalCount
- };
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- public async Task<IActionResult> ProductAddPopup(string blogPostId)
- {
- var blogPost = await _blogService.GetBlogPostById(blogPostId);
-
- if (!blogPost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return View(NoAccessToBlogPostMessage);
-
- var model = await _blogViewModelService.PrepareBlogModelAddProductModel(blogPostId);
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- public async Task<IActionResult> ProductAddPopupList(DataSourceRequest command,
- BlogProductModel.AddProductModel model)
- {
- model.SearchStoreId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;
+ var blogPost = await blogService.GetBlogPostById(id);
+ if (blogPost == null) return RedirectToAction("List");
+ if (!await PostScope.HasAccess(blogPost)) return RedirectToAction("List");
- var products = await _blogViewModelService.PrepareProductModel(model, command.Page, command.PageSize);
-
- var gridModel = new DataSourceResult {
- Data = products.products.ToList(),
- Total = products.totalCount
- };
-
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- public async Task<IActionResult> ProductAddPopup(string blogPostId, BlogProductModel.AddProductModel model)
- {
- var blogPost = await _blogService.GetBlogPostById(blogPostId);
-
- if (!blogPost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return View(NoAccessToBlogPostMessage);
-
- if (model.SelectedProductIds != null) await _blogViewModelService.InsertProductModel(blogPostId, model);
- return Content("");
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- public async Task<IActionResult> UpdateProduct(string blogPostId, BlogProductModel model)
- {
- var blogPost = await _blogService.GetBlogPostById(blogPostId);
-
- if (!blogPost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- ModelState.AddModelError("Blog", NoAccessToBlogPostMessage);
-
- if (ModelState.IsValid)
- {
- await _blogViewModelService.UpdateProductModel(model);
- return new JsonResult("");
- }
-
- return ErrorForKendoGridJson(ModelState);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- public async Task<IActionResult> DeleteProduct(string id)
- {
- var bp = await _blogService.GetBlogProductById(id) ?? throw new ArgumentException("No blog product found with the specified id");
- var blogPost = await _blogService.GetBlogPostById(bp.BlogPostId);
-
- if (!blogPost.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- ModelState.AddModelError("Blog", NoAccessToBlogPostMessage);
-
- if (ModelState.IsValid)
- {
- await _blogViewModelService.DeleteProductModel(id);
- return new JsonResult("");
- }
-
- return ErrorForKendoGridJson(ModelState);
- }
-
- #endregion
-
- #region Categories
-
- public IActionResult CategoryList()
- {
- return View();
- }
-
- [PermissionAuthorizeAction(PermissionActionName.List)]
- [HttpPost]
- public async Task<IActionResult> CategoryList(DataSourceRequest command)
- {
- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;
- var categories = await _blogService.GetAllBlogCategories(storeId);
- var gridModel = new DataSourceResult {
- Data = categories,
- Total = categories.Count
- };
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Create)]
- public async Task<IActionResult> CategoryCreate()
- {
- var model = new BlogCategoryModel();
- //locales
- await AddLocales(_languageService, model.Locales);
-
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
- public async Task<IActionResult> CategoryCreate(BlogCategoryModel model, bool continueEditing)
- {
- if (ModelState.IsValid)
- {
- model.Stores = [_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId];
- var blogCategory = model.ToEntity();
- blogCategory.SeName = SeoExtensions.GetSeName(
- string.IsNullOrEmpty(blogCategory.SeName) ? blogCategory.Name : blogCategory.SeName,
- _seoSettings.ConvertNonWesternChars, _seoSettings.AllowUnicodeCharsInUrls,
- _seoSettings.SeoCharConversion);
-
- await _blogService.InsertBlogCategory(blogCategory);
- Success(_translationService.GetResource("Admin.Content.Blog.BlogCategory.Added"));
- return continueEditing
- ? RedirectToAction("CategoryEdit", new { id = blogCategory.Id })
- : RedirectToAction(CategoryListAction);
- }
-
- //If we got this far, something failed, redisplay form
- //locales
- await AddLocales(_languageService, model.Locales);
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Preview)]
- public async Task<IActionResult> CategoryEdit(string id)
- {
- var blogCategory = await _blogService.GetBlogCategoryById(id);
- if (blogCategory == null)
- //No blog post found with the specified id
- return RedirectToAction(CategoryListAction);
-
- if (!blogCategory.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return RedirectToAction(CategoryListAction);
-
- var model = blogCategory.ToModel();
- //locales
- await AddLocales(_languageService, model.Locales, (locale, languageId) =>
- {
- locale.Name = blogCategory.GetTranslation(x => x.Name, languageId, false);
- });
+ var model = blogPost.ToModel(dateTimeService);
return View(model);
}
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
- public async Task<IActionResult> CategoryEdit(BlogCategoryModel model, bool continueEditing)
- {
- var blogCategory = await _blogService.GetBlogCategoryById(model.Id);
- if (blogCategory == null)
- //No blog post found with the specified id
- return RedirectToAction(CategoryListAction);
-
- if (!blogCategory.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return RedirectToAction(CategoryListAction);
-
- if (ModelState.IsValid)
- {
- model.Stores = [_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId];
- blogCategory = model.ToEntity(blogCategory);
- blogCategory.SeName = SeoExtensions.GetSeName(
- string.IsNullOrEmpty(blogCategory.SeName) ? blogCategory.Name : blogCategory.SeName,
- _seoSettings.ConvertNonWesternChars, _seoSettings.AllowUnicodeCharsInUrls,
- _seoSettings.SeoCharConversion);
- await _blogService.UpdateBlogCategory(blogCategory);
- Success(_translationService.GetResource("Admin.Content.Blog.BlogCategory.Updated"));
- if (continueEditing)
- {
- //selected tab
- await SaveSelectedTabIndex();
-
- return RedirectToAction("CategoryEdit", new { id = blogCategory.Id });
- }
-
- return RedirectToAction(CategoryListAction);
- }
-
- //If we got this far, something failed, redisplay form
-
- //locales
- await AddLocales(_languageService, model.Locales, (locale, languageId) =>
- {
- locale.Name = blogCategory.GetTranslation(x => x.Name, languageId, false);
- });
-
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- [HttpPost]
- public async Task<IActionResult> CategoryDelete(string id)
- {
- var blogCategory = await _blogService.GetBlogCategoryById(id);
- if (blogCategory == null)
- //No blog post found with the specified id
- return RedirectToAction(CategoryListAction);
-
- if (!blogCategory.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return RedirectToAction(CategoryListAction);
-
- if (ModelState.IsValid)
- {
- await _blogService.DeleteBlogCategory(blogCategory);
-
- Success(_translationService.GetResource("Admin.Content.Blog.BlogCategory.Deleted"));
- return RedirectToAction(CategoryListAction);
- }
-
- Error(ModelState);
- return RedirectToAction("CategoryEdit", new { id = blogCategory.Id });
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Preview)]
- [HttpPost]
- public async Task<IActionResult> CategoryPostList(string categoryId)
- {
- var blogCategory = await _blogService.GetBlogCategoryById(categoryId);
- if (blogCategory == null)
- return ErrorForKendoGridJson("blogCategory no exists");
-
- if (!blogCategory.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return ErrorForKendoGridJson(NoAccessToBlogCategoryMessage);
-
- var blogposts = new List<AdminShared.Models.Blogs.BlogCategoryPost>();
- foreach (var item in blogCategory.BlogPosts)
- {
- var post = new AdminShared.Models.Blogs.BlogCategoryPost {
- Id = item.Id,
- BlogPostId = item.BlogPostId
- };
- var _post = await _blogService.GetBlogPostById(item.BlogPostId);
- if (_post != null)
- post.Name = _post.Title;
-
- blogposts.Add(post);
- }
-
- var gridModel = new DataSourceResult {
- Data = blogposts,
- Total = blogCategory.BlogPosts.Count
- };
- return Json(gridModel);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- public async Task<IActionResult> CategoryPostDelete(string categoryId, string id)
- {
- var blogCategory = await _blogService.GetBlogCategoryById(categoryId);
- if (blogCategory == null)
- return ErrorForKendoGridJson("blogCategory no exists");
-
- if (!blogCategory.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- return ErrorForKendoGridJson(NoAccessToBlogCategoryMessage);
-
- if (ModelState.IsValid)
- {
- var post = blogCategory.BlogPosts.FirstOrDefault(x => x.Id == id);
- if (post != null)
- {
- blogCategory.BlogPosts.Remove(post);
- await _blogService.UpdateBlogCategory(blogCategory);
- }
-
- return new JsonResult("");
- }
-
- return ErrorForKendoGridJson(ModelState);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- public IActionResult BlogPostAddPopup(string categoryId)
- {
- var model = new AddBlogPostCategoryModel {
- CategoryId = categoryId
- };
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- public async Task<IActionResult> BlogPostAddPopup(AddBlogPostCategoryModel model)
- {
- if (model.SelectedBlogPostIds == null)
- {
- return Content("");
- }
-
- var blogCategory = await _blogService.GetBlogCategoryById(model.CategoryId);
- if (blogCategory == null)
- {
- return Content("");
- }
-
- if (!blogCategory.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- {
- return Content(NoAccessToBlogCategoryMessage);
- }
-
- await AddSelectedPostsToBlogCategory(blogCategory, model.SelectedBlogPostIds);
-
- return Content("");
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- public async Task<IActionResult> BlogPostAddPopupList(DataSourceRequest command, AddBlogPostCategoryModel model)
- {
- var gridModel = new DataSourceResult();
- model.SearchStoreId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;
-
- var posts = await _blogService.GetAllBlogPosts(model.SearchStoreId, blogPostName: model.SearchBlogTitle,
- pageIndex: command.Page - 1, pageSize: command.PageSize);
- gridModel.Data = posts.Select(x => new { x.Id, Name = x.Title });
- gridModel.Total = posts.TotalCount;
-
- return Json(gridModel);
- }
-
- private async Task AddSelectedPostsToBlogCategory(BlogCategory blogCategory, string[] postIds)
- {
- foreach (var id in postIds)
- {
- await AddPostToBlogCategoryIfValid(blogCategory, id);
- }
- }
-
- private async Task AddPostToBlogCategoryIfValid(BlogCategory blogCategory, string postId)
- {
- var post = await _blogService.GetBlogPostById(postId);
- if (post == null)
- {
- return;
- }
-
- if (!post.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))
- {
- // Skip posts that the user doesn't have access to
- return;
- }
-
- if (blogCategory.BlogPosts.Any(x => x.BlogPostId == postId))
- {
- // Skip if the post is already in the category
- return;
- }
-
- blogCategory.BlogPosts.Add(new Domain.Blogs.BlogCategoryPost { BlogPostId = postId });
- await _blogService.UpdateBlogCategory(blogCategory);
- }
-
- #endregion
-}
\ No newline at end of file
+}
diff --git a/src/Web/Grand.Web.Store/Models/Blogs/BlogCommentListModel.cs b/src/Web/Grand.Web.Store/Models/Blogs/BlogCommentListModel.cs
deleted file mode 100644
index 492b27387..000000000
--- a/src/Web/Grand.Web.Store/Models/Blogs/BlogCommentListModel.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Grand.Web.Store.Models.Blogs;
-
-/// <summary>
-/// View model for the blog comments list page, optionally filtered to one blog post.
-/// </summary>
-public class BlogCommentListModel
-{
- public string FilterByBlogPostId { get; set; }
-}