Esempio n. 1
0
        public ActionResult Boeken(int?vanaf, int?desc, int?filter, string search, int?mode)
        {
            Session.Remove("stap3");
            Session["stap2"] = "Boeken";
            Session["url2"]  = "/../admin/boeken";
            ViewBag.stap1    = Session["stap1"];
            ViewBag.url1     = Session["url1"];
            ViewBag.stap2    = Session["stap2"];
            ViewBag.url2     = Session["url2"];
            //mode == 1 -> json
            //mode == 0/null -> view

            //desc == 1 -> descending
            //desc == 0 -> ascending
            bool DisplayDeleted = false;

            if (bs.GetUser(User.Identity.Name).Roles.Any(r => r.RoleId == "95311bc7-8180-4c53-9e33-61fd254c21fc"))
            {
                DisplayDeleted = true;
            }

            if (search == null)
            {
                search = "";
            }

            List <Boek> res = new List <Boek>();

            if (!vanaf.HasValue)
            {
                vanaf = 0;
            }
            if (!desc.HasValue)
            {
                desc = 0;
            }
            if (!filter.HasValue)
            {
                filter = 0;
            }

            switch ((int)filter)
            {
            case 1:
                //boek naam
                if (desc == 1)
                {
                    res = bs.GetBoeken50FromSortNameZA((int)vanaf, search, DisplayDeleted);
                }
                else
                {
                    res = bs.GetBoeken50FromSortNameAZ((int)vanaf, search, DisplayDeleted);
                }
                break;

            case 2:
                //gebruiker naam
                if (desc == 1)
                {
                    res = bs.GetBoeken50FromSortUserZA((int)vanaf, search, DisplayDeleted);
                }
                else
                {
                    res = bs.GetBoeken50FromSortUserAZ((int)vanaf, search, DisplayDeleted);
                }
                break;

            case 4:
                if (desc == 1)
                {
                    res = bs.GetBoeken50FromSortDeletedZA((int)vanaf, search, DisplayDeleted);
                }
                else
                {
                    res = bs.GetBoeken50FromSortDeletedAZ((int)vanaf, search, DisplayDeleted);
                }
                break;

            default:
                if (desc == 1)
                {
                    res = bs.GetBoeken50FromSortNameZA((int)vanaf, search, DisplayDeleted);
                }
                else
                {
                    res = bs.GetBoeken50FromSortNameAZ((int)vanaf, search, DisplayDeleted);
                }
                break;
            }
            ViewBag.vanaf  = vanaf;
            ViewBag.desc   = desc;
            ViewBag.filter = filter;

            if (!mode.HasValue || (int)mode == 0)
            {
                return(View(res));
            }
            else
            {
                return(Json(JsonConvert.SerializeObject(res), JsonRequestBehavior.AllowGet));
            }
        }