Exemple #1
0
        public IActionResult Index(IFormCollection fc)
        {
            var pager   = new Pager(1);
            var profile = GetProfile();
            var model   = new AdminPostsModel {
                Profile = profile
            };

            var status = fc.ContainsKey("status-filter") ? fc["status-filter"].ToString() : "A";

            model.StatusFilter = GetStatusFilter(status);

            var selectedCategories = new List <string>();
            var dbCategories       = new List <Category>();

            model.CategoryFilter = _db.Categories.CategoryList(c => c.ProfileId == model.Profile.Id).ToList();
            if (fc.ContainsKey("category-filter"))
            {
                selectedCategories = fc["category-filter"].ToList();
                foreach (var ftr in model.CategoryFilter)
                {
                    if (selectedCategories.Contains(ftr.Value))
                    {
                        ftr.Selected = true;
                    }
                }
            }
            model.BlogPosts = _db.BlogPosts.ByFilter(status, selectedCategories, profile.Slug, pager).Result;
            model.Pager     = pager;

            return(View(_theme + "Index.cshtml", model));
        }
Exemple #2
0
        public IActionResult Index(int page = 1, string search = "")
        {
            if (page == 0)
            {
                page = 1;
            }
            var pager = new Pager(page);
            var model = new AdminPostsModel {
                Profile = GetProfile()
            };

            model.StatusFilter   = GetStatusFilter("A");
            model.CategoryFilter = _db.Categories.CategoryList(c => c.ProfileId == model.Profile.Id).ToList();

            if (string.IsNullOrEmpty(search))
            {
                model.BlogPosts = _db.BlogPosts.Find(p => p.Profile.IdentityName == User.Identity.Name, pager);
            }
            else
            {
                model.BlogPosts = _search.Find(pager, search, model.Profile.Slug).Result;
            }

            model.Pager = pager;

            return(View(_theme + "Index.cshtml", model));
        }
        public IActionResult Index(int page)
        {
            if (page == 0)
            {
                page = 1;
            }
            var pager = new Pager(page);
            var model = new AdminPostsModel {
                Profile = GetProfile()
            };

            model.BlogPosts = _db.BlogPosts.Find(p => p.Profile.IdentityName == User.Identity.Name, pager);
            model.Pager     = pager;

            return(View(_theme + "Index.cshtml", model));
        }
        public IActionResult Index(int page = 1, string user = "******", string status = "A", string cats = "", string search = "")
        {
            var pager   = new Pager(page);
            var profile = GetProfile();
            var model   = new AdminPostsModel {
                Profile = profile
            };

            if (model.Profile.IsAdmin)
            {
                model.Users = _db.Profiles.Find(p => p.IdentityName != model.Profile.IdentityName);
            }

            var userProfile = model.Profile;

            if (user != "0")
            {
                userProfile = _db.Profiles.Single(p => p.Id == int.Parse(user));
            }

            model.StatusFilter = GetStatusFilter(status);

            var selectedCategories = new List <string>();
            var dbCategories       = new List <Category>();

            model.CategoryFilter = _db.Categories.CategoryList(c => c.ProfileId == userProfile.Id).ToList();
            if (!string.IsNullOrEmpty(cats))
            {
                selectedCategories = cats.Split(',').ToList();
                foreach (var ftr in model.CategoryFilter)
                {
                    if (selectedCategories.Contains(ftr.Value))
                    {
                        ftr.Selected = true;
                    }
                }
            }
            model.BlogPosts = _db.BlogPosts.ByFilter(status, selectedCategories, userProfile.Slug, pager).Result;
            model.Pager     = pager;

            var anyPost = _db.BlogPosts.Find(p => p.ProfileId == userProfile.Id).FirstOrDefault();

            ViewBag.IsFirstPost = anyPost == null;

            return(View(_theme + "Index.cshtml", model));
        }
Exemple #5
0
        public async Task <IActionResult> Index(int page = 1, string user = "******", string status = "A", string cats = "", string search = "")
        {
            var profile = GetProfile();

            var fields = await _db.CustomFields.GetCustomFields(CustomType.Profile, profile.Id);

            var pageSize = BlogSettings.ItemsPerPage;

            if (fields.ContainsKey(Constants.PostListSize))
            {
                pageSize = int.Parse(fields[Constants.PostListSize]);
            }

            var pager = new Pager(page, pageSize);
            var model = new AdminPostsModel {
                Profile = profile
            };

            model.CustomFields = fields;

            if (model.Profile.IsAdmin)
            {
                model.Users = _db.Profiles.Find(p => p.IdentityName != model.Profile.IdentityName);
            }

            var userProfile = model.Profile;

            if (user != "0" && profile.IsAdmin)
            {
                userProfile = _db.Profiles.Single(p => p.Id == int.Parse(user));
            }

            model.StatusFilter = GetStatusFilter(status);

            var selectedCategories = new List <string>();
            var dbCategories       = new List <Category>();

            model.CategoryFilter = _db.Categories.CategoryList(c => c.ProfileId == userProfile.Id).ToList();
            if (!string.IsNullOrEmpty(cats))
            {
                selectedCategories = cats.Split(',').ToList();
                foreach (var ftr in model.CategoryFilter)
                {
                    if (selectedCategories.Contains(ftr.Value))
                    {
                        ftr.Selected = true;
                    }
                }
            }

            if (string.IsNullOrEmpty(search))
            {
                model.BlogPosts = await _db.BlogPosts.ByFilter(status, selectedCategories, userProfile.Slug, pager);
            }
            else
            {
                model.BlogPosts = await _search.Find(pager, search, userProfile.Slug);
            }

            model.Pager = pager;

            var anyPost = _db.BlogPosts.Find(p => p.ProfileId == userProfile.Id).FirstOrDefault();

            ViewBag.IsFirstPost = anyPost == null;

            return(View(_theme + "Index.cshtml", model));
        }