예제 #1
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));
        }
예제 #2
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"));
        }
예제 #3
0
        public ActionResult Index()
        {
            var nccTranslator = new NccTranslator(CurrentLanguage);

            ViewBag.TotalUser = _userManager.Users.Count();

            ViewBag.TotalPublishedPage = _pageService.LoadAllByPageStatus(NccPage.NccPageStatus.Published).Count();
            ViewBag.TotalPage          = _pageService.LoadAll(true).Count();


            ViewBag.TotalCategory      = _categoryService.LoadAll(true).Count();
            ViewBag.TotalTag           = _tagService.LoadAll(true).Count();
            ViewBag.TotalPublishedPost = _postService.Count(true, true, true, true);
            ViewBag.TotalPost          = _postService.LoadAll(true).Count();
            ViewBag.TotalComments      = _commentsService.LoadAll(true).Count();

            return(View());
        }
예제 #4
0
        public ActionResult Index()
        {
            var webSite  = new NccWebSite();
            var webSites = _webSiteService.LoadAll();

            if (webSites != null && webSites.Count > 0)
            {
                webSite = webSites.FirstOrDefault();
            }
            ViewBag.TotalPublishedPage = _pageService.LoadAllByPageStatus(NccPage.NccPageStatus.Published).Count();
            ViewBag.TotalPage          = _pageService.LoadAll(true).Count();
            ViewBag.TotalPublishedPost = _postService.Count(true, true, true, true);
            ViewBag.TotalPost          = _postService.LoadAll(true).Count();
            ViewBag.TotalUser          = _userManager.Users.Count();
            ViewBag.TotalModule        = _moduleService.LoadAll().Count();
            ViewBag.TotalTheme         = GlobalContext.Themes.Count();
            return(View(webSite));
        }
예제 #5
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));
        }
예제 #6
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
            }));
        }