Exemplo n.º 1
0
 public NccPageService(NccPageRepository entityRepository, NccPageDetailsRepository nccPageDetailsRepository) : base(entityRepository, new List <string> {
     "Parent", "PageDetails"
 })
 {
     _entityRepository         = entityRepository;
     _nccPageDetailsRepository = nccPageDetailsRepository;
 }
Exemplo n.º 2
0
        public static async Task SaveBasicData(NccUser nccUser, NccDbContext nccDbConetxt, UserManager <NccUser> userManager, RoleManager <NccRole> roleManager, NccSignInManager <NccUser> signInManager, WebSiteInfo setupInfo)
        {
            string enDemoTitle   = "";
            string enDemoSlug    = "";
            string enDemoContent = "";
            string bnDemoTitle   = "";
            string bnDemoSlug    = "";
            string bnDemoContent = "";

            //var webSiteRepository = new NccWebSiteRepository(nccDbConetxt);
            //var webSiteInfoRepository = new NccWebSiteInfoRepository(nccDbConetxt);
            //var webSiteService = new NccWebSiteService(webSiteRepository, webSiteInfoRepository);

            #region Create a sample page
            var nccPageRepository        = new NccPageRepository(nccDbConetxt);
            var nccPageDetailsRepository = new NccPageDetailsRepository(nccDbConetxt);
            var nccPageService           = new NccPageService(nccPageRepository, nccPageDetailsRepository);

            try
            {
                enDemoTitle   = "Sample Page ";
                enDemoSlug    = "Sample-Page";
                enDemoContent = "This is a sample page.";
                bnDemoTitle   = "নমুনা পৃষ্ঠা ";
                bnDemoSlug    = "নমুনা-পৃষ্ঠা";
                bnDemoContent = "এটি একটি নমুনা পাতা।";

                NccPage page = new NccPage();
                page.Metadata    = "DEMODATA";
                page.PublishDate = DateTime.Now;
                page.PageStatus  = NccPageStatus.Published;
                page.PageType    = NccPageType.Public;
                page.Layout      = "SiteLayout";
                page.CreateBy    = page.ModifyBy = 1;
                page.Name        = enDemoTitle;

                foreach (var item in SupportedCultures.Cultures)
                {
                    NccPageDetails _nccPageDetails = new NccPageDetails();
                    _nccPageDetails.Language = item.TwoLetterISOLanguageName;
                    if (item.TwoLetterISOLanguageName == "en")
                    {
                        _nccPageDetails.Title           = enDemoTitle;
                        _nccPageDetails.Slug            = enDemoSlug;
                        _nccPageDetails.Name            = enDemoSlug;
                        _nccPageDetails.Content         = "<h1 style=\"text-align:center\">" + enDemoTitle + "</h1><p>" + enDemoContent + "</p>";
                        _nccPageDetails.MetaDescription = enDemoTitle + " " + enDemoContent;
                    }
                    else if (item.TwoLetterISOLanguageName == "bn")
                    {
                        _nccPageDetails.Title           = bnDemoTitle;
                        _nccPageDetails.Slug            = bnDemoSlug;
                        _nccPageDetails.Name            = bnDemoSlug;
                        _nccPageDetails.Content         = "<h1 style=\"text-align:center\">" + bnDemoTitle + "</h1><p>" + bnDemoContent + "</p>";
                        _nccPageDetails.MetaDescription = bnDemoTitle + " " + bnDemoContent;
                    }
                    page.PageDetails.Add(_nccPageDetails);
                }
                nccPageService.Save(page);
            }
            catch (Exception ex)
            {
            }
            #endregion

            #region Create a sample category
            var categoryRepository = new NccCategoryRepository(nccDbConetxt);
            var categoryService    = new NccCategoryService(categoryRepository);

            try
            {
                enDemoTitle = "Sample Category ";
                enDemoSlug  = "Sample-Category";
                bnDemoTitle = "নমুনা ক্যাটাগরি ";
                bnDemoSlug  = "নমুনা-ক্যাটাগরি";
                NccCategory item = new NccCategory();
                item.Metadata      = "DEMODATA";
                item.Name          = enDemoTitle;
                item.CategoryImage = "/media/Images/2017/06/image-slider-0.jpg";
                foreach (var lang in SupportedCultures.Cultures)
                {
                    NccCategoryDetails _nccDetails = new NccCategoryDetails();
                    _nccDetails.Language = lang.TwoLetterISOLanguageName;
                    if (lang.TwoLetterISOLanguageName == "en")
                    {
                        _nccDetails.Title = enDemoTitle;
                        _nccDetails.Slug  = enDemoSlug;
                        _nccDetails.Name  = enDemoSlug;
                    }
                    else if (lang.TwoLetterISOLanguageName == "bn")
                    {
                        _nccDetails.Title = bnDemoTitle;
                        _nccDetails.Slug  = bnDemoSlug;
                        _nccDetails.Name  = bnDemoSlug;
                    }
                    item.CategoryDetails.Add(_nccDetails);
                }
                categoryService.Save(item);
            }
            catch (Exception ex) { }
            #endregion
            //var tagRepository = new NccTagRepository(nccDbConetxt);
            //var tagService = new NccTagService(tagRepository);

            #region Create a sample post
            var postRepository        = new NccPostRepository(nccDbConetxt);
            var postDetailsRepository = new NccPostDetailsRepository(nccDbConetxt);
            var postService           = new NccPostService(postRepository, postDetailsRepository);

            try
            {
                enDemoTitle   = "Sample Post ";
                enDemoSlug    = "Sample-Post";
                enDemoContent = "This is a sample post.";
                bnDemoTitle   = "নমুনা পোস্ট ";
                bnDemoSlug    = "নমুনা-পোস্ট";
                bnDemoContent = "এটি একটি নমুনা পোস্ট।";
                var categoryList = categoryService.LoadAll();

                NccPost post = new NccPost();
                post.Metadata     = "DEMODATA";
                post.PublishDate  = DateTime.Now;
                post.PostStatus   = NccPostStatus.Published;
                post.PostType     = NccPostType.Public;
                post.Layout       = "SiteLayout";
                post.CreateBy     = post.ModifyBy = 1;
                post.Name         = enDemoTitle;
                post.AllowComment = true;
                post.ThumImage    = "/media/Images/2017/06/image-slider-2.jpg";
                foreach (var postItem in SupportedCultures.Cultures)
                {
                    NccPostDetails _nccPostDetails = new NccPostDetails();
                    _nccPostDetails.Language = postItem.TwoLetterISOLanguageName;
                    if (postItem.TwoLetterISOLanguageName == "en")
                    {
                        _nccPostDetails.Title           = enDemoTitle;
                        _nccPostDetails.Slug            = enDemoSlug;
                        _nccPostDetails.Name            = enDemoSlug;
                        _nccPostDetails.Content         = "<h1 style=\"text-align:center\">" + enDemoTitle + "</h1><hr />" + enDemoContent;
                        _nccPostDetails.MetaDescription = enDemoTitle + " " + enDemoContent;
                    }
                    else if (postItem.TwoLetterISOLanguageName == "bn")
                    {
                        _nccPostDetails.Title           = bnDemoTitle;
                        _nccPostDetails.Slug            = bnDemoSlug;
                        _nccPostDetails.Name            = bnDemoSlug;
                        _nccPostDetails.Content         = "<h1 style=\"text-align:center\">" + bnDemoTitle + "</h1><hr />" + bnDemoContent;
                        _nccPostDetails.MetaDescription = bnDemoTitle + " " + bnDemoContent;
                    }
                    post.PostDetails.Add(_nccPostDetails);
                }
                postService.Save(post);

                try
                {
                    post            = postService.Get(post.Id, true);
                    post.Categories = new List <NccPostCategory>();
                    var temp = categoryList.FirstOrDefault();
                    if (temp != null)
                    {
                        if (post.Categories.Where(x => x.CategoryId == temp.Id).Count() <= 0)
                        {
                            post.Categories.Add(new NccPostCategory()
                            {
                                Post = post, CategoryId = temp.Id
                            });
                        }
                    }
                    postService.Update(post);
                }
                catch (Exception ex) { }
            }
            catch (Exception ex) { }
            #endregion

            #region Create a sample comment
            var commentsRepository = new NccCommentsRepository(nccDbConetxt);
            var commentsService    = new NccCommentsService(commentsRepository);
            try
            {
                enDemoContent = "This is a sample comment.";
                bnDemoContent = "এটি একটি নমুনা মন্তব্য।";
                NccComment commentItem = new NccComment();
                commentItem.Metadata = "DEMODATA";
                commentItem.Name     = "Sample Comments";
                commentItem.Content  = enDemoContent;
                if (Language == "bn")
                {
                    commentItem.Content = bnDemoContent;
                }
                commentItem.CommentStatus = NccComment.NccCommentStatus.Approved;
                commentItem.Post          = postService.LoadAll().FirstOrDefault();
                commentsService.Save(commentItem);
            }
            catch (Exception ex) { }
            #endregion

            #region Create sample menu
            var menuRepository     = new NccMenuRepository(nccDbConetxt);
            var menuItemRepository = new NccMenuItemRepository(nccDbConetxt);
            var menuService        = new NccMenuService(menuRepository, menuItemRepository);

            try
            {
                NccMenu nccMenu = new NccMenu()
                {
                    Name         = "Main Menu",
                    Position     = "Navigation",
                    MenuOrder    = 1,
                    MenuLanguage = ""
                };
                if (Language == "bn")
                {
                    nccMenu.MenuItems.Add(new NccMenuItem()
                    {
                        Action     = "",
                        Controller = "",
                        Data       = "",
                        //Id = item.Id,
                        MenuActionType = NccMenuItem.ActionType.Url,
                        MenuOrder      = 1,
                        Module         = "",
                        Name           = "হোম",
                        Target         = "_self",
                        Url            = "/"
                    });
                    nccMenu.MenuItems.Add(new NccMenuItem()
                    {
                        Action     = "",
                        Controller = "",
                        Data       = "",
                        //Id = item.Id,
                        MenuActionType = NccMenuItem.ActionType.Url,
                        MenuOrder      = 2,
                        Module         = "",
                        Name           = "নমুনা পৃষ্ঠা",
                        Target         = "_self",
                        Url            = "/নমুনা-পৃষ্ঠা"
                    });
                    nccMenu.MenuItems.Add(new NccMenuItem()
                    {
                        Action     = "",
                        Controller = "",
                        Data       = "",
                        //Id = item.Id,
                        MenuActionType = NccMenuItem.ActionType.Url,
                        MenuOrder      = 3,
                        Module         = "",
                        Name           = "ব্লগ পোস্ট",
                        Target         = "_self",
                        Url            = "/Post"
                    });
                    nccMenu.MenuItems.Add(new NccMenuItem()
                    {
                        Action     = "",
                        Controller = "",
                        Data       = "",
                        //Id = item.Id,
                        MenuActionType = NccMenuItem.ActionType.Url,
                        MenuOrder      = 4,
                        Module         = "",
                        Name           = "ব্লগ বিভাগ",
                        Target         = "_self",
                        Url            = "/Category"
                    });
                }
                else
                {
                    nccMenu.MenuItems.Add(new NccMenuItem()
                    {
                        Action     = "",
                        Controller = "",
                        Data       = "",
                        //Id = item.Id,
                        MenuActionType = NccMenuItem.ActionType.Url,
                        MenuOrder      = 1,
                        Module         = "",
                        Name           = "Home",
                        Target         = "_self",
                        Url            = "/"
                    });
                    nccMenu.MenuItems.Add(new NccMenuItem()
                    {
                        Action     = "",
                        Controller = "",
                        Data       = "",
                        //Id = item.Id,
                        MenuActionType = NccMenuItem.ActionType.Url,
                        MenuOrder      = 2,
                        Module         = "",
                        Name           = "Sample Page",
                        Target         = "_self",
                        Url            = "/Sample-Page"
                    });
                    nccMenu.MenuItems.Add(new NccMenuItem()
                    {
                        Action     = "",
                        Controller = "",
                        Data       = "",
                        //Id = item.Id,
                        MenuActionType = NccMenuItem.ActionType.Url,
                        MenuOrder      = 3,
                        Module         = "",
                        Name           = "Blog Posts",
                        Target         = "_self",
                        Url            = "/Post"
                    });
                    nccMenu.MenuItems.Add(new NccMenuItem()
                    {
                        Action     = "",
                        Controller = "",
                        Data       = "",
                        //Id = item.Id,
                        MenuActionType = NccMenuItem.ActionType.Url,
                        MenuOrder      = 4,
                        Module         = "",
                        Name           = "Blog Categories",
                        Target         = "_self",
                        Url            = "/Category"
                    });
                }

                menuService.Save(nccMenu);
            }
            catch (Exception ex) { }
            #endregion

            #region Create sample widget
            //var currentWebsite = nccWebSiteService.LoadAll().FirstOrDefault();
            //var nccWebSiteWidget = new NccWebSiteWidget()
            //{
            //    WebSite = currentWebsite,
            //    WidgetConfigJson = "",
            //    ModuleId = "NetCoreCMS.Core.Modules.Cms",
            //    WidgetId = "NetCoreCms.Modules.Cms.CmsSearch",
            //    ThemeId = "com.NetCoreCMS.themes.NccSeventeen",
            //    LayoutName = "SiteLayout",
            //    Zone = "RightSidebar",
            //    WidgetOrder = 1,
            //    WidgetData = "",
            //};
            //nccWebSiteWidgetService.Save(nccWebSiteWidget);
            #endregion
        }
Exemplo n.º 3
0
 public NccPageService(NccPageRepository entityRepository)
 {
     _entityRepository = entityRepository;
 }
Exemplo n.º 4
0
 public NccPageService(NccPageRepository entityRepository, NccPageDetailsRepository nccPageDetailsRepository)
 {
     _entityRepository         = entityRepository;
     _nccPageDetailsRepository = nccPageDetailsRepository;
 }