Пример #1
0
        public ActionResult Activities(int?vanaf, int?desc, int?filter, string search, int?mode)
        {
            Session.Remove("stap3");
            Session["stap2"] = "activities";
            Session["url2"]  = "/../admin/Activities";
            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
            if (search == null)
            {
                search = "";
            }
            List <Activiteit> res = new List <Activiteit>();
            bool DisplayDeleted   = false;

            //if (bs.GetUser(User.Identity.Name).Roles.Any(r => r.RoleId == "32a0d6e2-3270-485e-88b9-0b0a6e59ff09")) DisplayDeleted = true;
            if (bs.GetUser(User.Identity.Name).Roles.Any(r => r.RoleId == "95311bc7-8180-4c53-9e33-61fd254c21fc"))
            {
                DisplayDeleted = true;
            }


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

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

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

            case 3:
                //poi
                if (desc == 1)
                {
                    res = bs.GetActiviteiten50FromSortPoiZA((int)vanaf, search, DisplayDeleted);
                }
                else
                {
                    res = bs.GetActiviteiten50FromSortPoiAZ((int)vanaf, search, DisplayDeleted);
                }
                break;

            case 4:
                //poi
                if (desc == 1)
                {
                    res = bs.getActiviteiten50FromSortDeletedZA((int)vanaf, search, DisplayDeleted);
                }
                else
                {
                    res = bs.getActiviteiten50FromSortDeletedAZ((int)vanaf, search, DisplayDeleted);
                }
                break;

            default:
                if (desc == 1)
                {
                    res = bs.GetActiviteiten50FromSortNameZA((int)vanaf, search, DisplayDeleted);
                }
                else
                {
                    res = bs.GetActiviteiten50FromSortNameAZ((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));
            }
        }