Пример #1
0
        // GET: Bookmarks
        public ActionResult Index()
        {
            User loggedUser = OnlineUsers.GetSessionUser();

            InitSessionSortAndFilter();
            var Query = DB.BookmarkList(loggedUser, (string)Session["BookmarkSortBy"], (bool)Session["BookmarkSortAscendant"]);



            int categorieFilter = (int)Session["BookmarkFilterByCategory"];
            int ownerShipFilter = (int)Session["BookmarkFilterByOwnership"];

            ViewBag.Categories  = DB.Categories;
            ViewBag.Users       = DB.Users;
            ViewBag.CurrentUser = loggedUser;

            if (categorieFilter != -1)
            {
                string categorie_name = DB.Categories.Where(x => x.Id == categorieFilter).FirstOrDefault().Name.ToString();
                Query = Query.Where(x => x.CategoryName == categorie_name).ToList();
            }

            if (ownerShipFilter != -1)
            {
                if (ownerShipFilter == -2)
                {
                    Query = Query.Where(x => x.Shared).ToList();
                }
                else if (ownerShipFilter == -3)
                {
                    Query = Query.Where(x => !x.Shared).ToList();
                }
                else
                {
                    Query = Query.Where(x => x.OwnerId == ownerShipFilter && !x.Shared).ToList();
                }
            }


            return(View(Query));
        }