Exemplo n.º 1
0
 public override object PrepareViewModel()
 {
     if (bpsViewModel.CategoryId > 0)
     {
         if (bpsViewModel.IsSticky || bpsViewModel.IsFeatured)
         {
             bpsViewModel.PostList = _nccPostService.LoadSpecialPosts(bpsViewModel.IsSticky, bpsViewModel.IsFeatured).Where(x => x.Categories.Any(y => y.CategoryId == bpsViewModel.CategoryId)).ToList();
         }
         else
         {
             bpsViewModel.PostList = _nccPostService.Load(0, bpsViewModel.TotalPost, true, true, true, true, null, null, bpsViewModel.CategoryId);
         }
     }
     else
     {
         if (bpsViewModel.IsSticky || bpsViewModel.IsFeatured)
         {
             bpsViewModel.PostList = _nccPostService.LoadSpecialPosts(bpsViewModel.IsSticky, bpsViewModel.IsFeatured);
         }
         else
         {
             bpsViewModel.PostList = _nccPostService.Load(0, bpsViewModel.TotalPost, true, true);
         }
     }
     return(bpsViewModel);
 }
Exemplo n.º 2
0
        public ActionResult Index(string slug = "", int page = 0)
        {
            ViewBag.CurrentLanguage = CurrentLanguage;
            if (!string.IsNullOrEmpty(slug))
            {
                NccCategory item = _nccCategoryService.GetBySlug(slug);
                if (item != null)
                {
                    ViewBag.Slug     = slug;
                    ViewBag.Category = item;
                    var postPerPage = GlobalContext.WebSite.WebSitePageSize;
                    var totalPost   = _nccPostService.Count(true, true, true, true, null, null, item.Id, 0);
                    var allPost     = _nccPostService.Load(page, postPerPage, true, true, true, true, null, null, item.Id, 0);

                    ViewBag.CurrentPage = page;
                    ViewBag.PostPerPage = postPerPage;
                    ViewBag.TotalPost   = totalPost;

                    return(View("Details", allPost));
                }
            }
            var ItemList = _nccCategoryService.LoadAll(true).OrderByDescending(x => x.CreationDate).ToList();

            return(View(ItemList));
        }
Exemplo n.º 3
0
        public ActionResult Index(int pageNumber = 0)
        {
            if (SetupHelper.IsDbCreateComplete && SetupHelper.IsAdminCreateComplete)
            {
                var postPerPage   = GlobalContext.WebSite.WebSitePageSize;
                var totalPost     = _postService.Count(true, true, true, false);
                var stickyPosts   = _postService.LoadSpecialPosts(true, false);
                var featuredPosts = _postService.LoadSpecialPosts(false, true);
                var allPost       = _postService.Load(pageNumber, postPerPage, true, true, false, false);

                return(View(new HomePageViewModel()
                {
                    AllPosts = allPost,
                    CurrentLanguage = CurrentLanguage,
                    FeaturedPosts = featuredPosts,
                    StickyPosts = stickyPosts,
                    PageNumber = pageNumber,
                    PostPerPage = postPerPage,
                    TotalPost = totalPost,
                    PreviousPage = pageNumber - 1,
                    NextPage = pageNumber + 1,
                    TotalPage = (int)Math.Ceiling(totalPost / (decimal)postPerPage),
                }));
            }
            return(Redirect("/SetupHome/Index"));
        }
Exemplo n.º 4
0
        public StartupViewModel PrepareStartupViewData()
        {
            var setupConfig        = SetupHelper.LoadSetup();
            var model              = new StartupViewModel();
            var moduleSiteMenuList = new List <SiteMenuItem>();
            var roleList           = _nccPermissionService.LoadAll().Select(x => new { Name = x.Name, Value = x.Id }).ToList();

            model.Url         = setupConfig.StartupUrl;
            model.StartupType = setupConfig.StartupType;

            //original was Slug , Title
            model.Pages      = new SelectList(_pageService.LoadAll(true), "Id", "Name", setupConfig.StartupData);
            model.Posts      = new SelectList(_postService.Load(0, 100, true, true), "Id", "Name", setupConfig.StartupData);
            model.Categories = new SelectList(_categoryService.LoadAll(true), "Id", "Name", setupConfig.StartupData);
            NccMenuHelper.GetModulesSiteMenus().Select(x => x.Value).ToList().ForEach(x => moduleSiteMenuList.AddRange(x));
            model.ModuleSiteMenus = new SelectList(moduleSiteMenuList, "Url", "Url", setupConfig.StartupData);
            model.Roles           = new SelectList(roleList, "Value", "Name");

            ViewBag.RoleStartups = _startupService.LoadAll(true, 0, "", false);

            ViewBag.DefaultChecked  = "";
            ViewBag.PageChecked     = "";
            ViewBag.CategoryChecked = "";
            ViewBag.PostChecked     = "";
            ViewBag.ModuleChecked   = "";

            if (setupConfig.StartupType == StartupTypeText.Page)
            {
                ViewBag.PageChecked = "checked";
            }
            else if (setupConfig.StartupType == StartupTypeText.Post)
            {
                ViewBag.PostChecked = "checked";
            }
            else if (setupConfig.StartupType == StartupTypeText.Category)
            {
                ViewBag.CategoryChecked = "checked";
            }
            else if (setupConfig.StartupType == StartupTypeText.Module)
            {
                ViewBag.ModuleChecked = "checked";
            }
            else
            {
                ViewBag.DefaultChecked = "checked";
            }

            return(model);
        }
Exemplo n.º 5
0
        public bool CreateComments(int totalCount)
        {
            int    currentCount = _commentsService.LoadAll().Count();
            var    postList     = _postService.Load(0, 1000, true, false, true, true);
            string itemName     = "Test-Comment-";

            for (int i = 1; i <= totalCount; i++)
            {
                NccComment item = new NccComment();
                item.Metadata      = "DEMODATA";
                item.Name          = itemName + (currentCount + i).ToString();
                item.Content       = item.Name + " -> " + commentsDemoContent;
                item.CommentStatus = NccComment.NccCommentStatus.Approved;
                item.Post          = GetRandomPost(postList);

                _commentsService.Save(item);
                //ShowMessage(totalCount + " Comments created successfully", Framework.Core.Mvc.Views.MessageType.Success);
            }

            return(true);
        }
Exemplo n.º 6
0
        public ActionResult Index(string name = "", int page = 0)
        {
            ViewBag.CurrentLanguage = CurrentLanguage;
            if (!string.IsNullOrEmpty(name))
            {
                var item = _nccTagService.Get(name);
                if (item != null)
                {
                    ViewBag.Name = name;
                    ViewBag.Tag  = item;
                    var postPerPage = GlobalContext.WebSite.WebSitePageSize;
                    var totalPost   = _nccPostService.Count(true, true, true, true, null, null, 0, item.Id);
                    var allPost     = _nccPostService.Load(page, postPerPage, true, true, true, true, null, null, 0, item.Id);

                    ViewBag.CurrentPage = page;
                    ViewBag.PostPerPage = postPerPage;
                    ViewBag.TotalPost   = totalPost;
                    return(View("Details", allPost));
                }
            }
            var allPosts = _nccTagService.LoadAll(true).OrderByDescending(x => x.Posts.Count).ToList();

            return(View(allPosts));
        }
Exemplo n.º 7
0
        public JsonResult ManageAjax(int draw, int start, int length)
        {
            var  data            = new List <object>();
            long recordsTotal    = 0;
            long recordsFiltered = 0;

            try
            {
                string searchText = HttpContext.Request.Form["search[value]"];
                searchText = searchText.Trim();
                #region OrderBy and Direction
                string orderBy  = HttpContext.Request.Form["order[0][column]"];
                string orderDir = HttpContext.Request.Form["order[0][dir]"];
                if (!string.IsNullOrEmpty(orderDir))
                {
                    orderDir = orderDir.ToUpper();
                }
                if (!string.IsNullOrEmpty(orderBy))
                {
                    switch (orderBy)
                    {
                    case "0":
                        orderBy = "name";
                        break;

                    case "5":
                        orderBy = "publishdate";
                        break;

                    default:
                        orderBy = "";
                        break;
                    }
                }
                #endregion

                recordsTotal    = _nccPostService.Count(false, false, false, true, null, null, 0, 0, 0, searchText);
                recordsFiltered = recordsTotal;
                List <NccPost> itemList       = _nccPostService.Load(start, length, false, false, false, true, null, null, 0, 0, 0, searchText, orderBy, orderDir);
                string         controllerName = "Post";
                foreach (var item in itemList)
                {
                    var str  = new List <string>();
                    var temp = "";
                    #region Title
                    temp = "";
                    if (GlobalContext.WebSite.IsMultiLangual)
                    {
                        foreach (var details in item.PostDetails)
                        {
                            if (!string.IsNullOrEmpty(temp))
                            {
                                temp += "<br />";
                            }
                            temp += "<b>" + details.Language + ":</b> " + details.Title;
                        }
                    }
                    else
                    {
                        temp = item.Name;
                    }
                    str.Add(temp);
                    #endregion
                    if (item.Parent != null)
                    {
                        str.Add(item.Parent.PostDetails.FirstOrDefault().Title);
                    }
                    else
                    {
                        str.Add("-");
                    }

                    if (item.CreateBy == item.ModifyBy)
                    {
                        str.Add(_nccUserService.Get(item.CreateBy)?.UserName);
                    }
                    else
                    {
                        str.Add("<b>Cr:</b> " + _nccUserService.Get(item.CreateBy)?.UserName + "<br /><b>Mo:</b> " + _nccUserService.Get(item.ModifyBy)?.UserName);
                    }
                    #region Categories
                    temp = "";
                    foreach (var cat in item.Categories)
                    {
                        if (temp != "")
                        {
                            temp += ", ";
                        }
                        temp += cat.Category.Name;
                    }
                    str.Add(temp);
                    #endregion
                    #region Tags
                    temp = "";
                    foreach (var tag in item.Tags)
                    {
                        if (temp != "")
                        {
                            temp += ", ";
                        }
                        temp += tag.Tag.Name;
                    }
                    str.Add(temp);
                    #endregion

                    str.Add(item.PostStatus == NccPost.NccPostStatus.Published ? NccPost.NccPostStatus.Published.ToString() + ": " + item.PublishDate.ToString("yyyy-MM-dd hh:mm tt") : "Update: " + item.ModificationDate.ToString("yyyy-MM-dd hh:mm tt"));

                    str.Add(item.Layout);
                    str.Add(item.PostType.ToString());
                    str.Add("[Post Id=\"" + item.Id + "\" Post]");

                    string actionLink = " <a href='" + Url.Action("CreateEdit", controllerName, new { id = item.Id.ToString() }) + "' class='btn btn-xs btn-primary btn-outline'>Edit</a> ";
                    //if (item.Status == EntityStatus.Active)
                    //    actionLink += " <a href='" + Url.Action("StatusUpdate", controllerName, new { id = item.Id.ToString() }) + "' class='btn btn-xs btn-danger btn-outline'>Inactive</a> ";
                    //else
                    //    actionLink += " <a href='" + Url.Action("StatusUpdate", controllerName, new { id = item.Id.ToString() }) + "' class='btn btn-xs btn-success btn-outline'>Active</a> ";
                    actionLink += " <a href='" + Url.Action("Delete", controllerName, new { id = item.Id.ToString() }) + "' class='btn btn-xs btn-danger'>Delete</a> ";
                    if (GlobalContext.WebSite.IsMultiLangual == true)
                    {
                        actionLink += "";
                        foreach (var Details in item.PostDetails)
                        {
                            actionLink += " <a href='/" + Details.Language + "/Post/" + Details.Slug + "' target='_blank' class='btn btn-outline btn-info btn-xs'><i class='fa fa-eye'></i> " + Details.Language + "</a> ";
                        }
                    }
                    else
                    {
                        actionLink += " <a href='/Post/" + item.PostDetails.Where(x => x.Language == GlobalContext.WebSite.Language).FirstOrDefault().Slug + "'  target='_blank' class='btn btn-outline btn-info btn-xs'><i class='fa fa-eye'></i> " + item.PostDetails.Where(x => x.Language == GlobalContext.WebSite.Language).FirstOrDefault().Language + "</a> ";
                    }
                    str.Add(actionLink);
                    data.Add(str);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }

            return(Json(new
            {
                draw = draw,
                recordsTotal = recordsTotal,
                recordsFiltered = recordsFiltered,
                start = start,
                length = length,
                data = data
            }));
        }