public ActionResult VolunteerAllocation(string id, int page, string searching)
 {
     try
     {
         page         = UniversalFunctions.GetCurrentPage(page);
         ViewBag.Page = page;
         List <Volunteer> volunteers = volunteerManager.GetListOfVolunteers();
         volunteers      = VolunteerFunctions.GetVolunteerAfterSorting(volunteers, "Active_desc");
         ViewBag.counter = volunteers.Count();
         int nrofdocs = UniversalFunctions.GetNumberOfItemPerPageFromSettings(TempData);
         ViewBag.nrofdocs = nrofdocs;
         string stringofids = VolunteerFunctions.GetStringOfIds(volunteers);
         ViewBag.stringofids = stringofids;
         volunteers          = VolunteerFunctions.GetVolunteersAfterPaging(volunteers, page, nrofdocs);
         List <Event> events = eventManager.GetListOfEvents();
         ViewBag.strname   = EventFunctions.GetAllocatedVolunteersString(events, id);
         ViewBag.Eventname = EventFunctions.GetNameOfEvent(events, id);
         ViewBag.Evid      = id;
         volunteers        = VolunteerFunctions.GetVolunteersAfterSearching(volunteers, searching);
         return(View(volunteers));
     }
     catch
     {
         return(RedirectToAction("Localserver", "Home"));
     }
 }
        public ActionResult Index(string searchedFullname, string searchedContact, string sortOrder, bool Active, bool HasCar, bool HasDrivingLicence, DateTime lowerdate, DateTime upperdate, int page, string gender, string searchedAddress, string searchedworkplace, string searchedOccupation, string searchedRemarks, int searchedHourCount)
        {
            try
            {
                int nrofdocs = UniversalFunctions.GetNumberOfItemPerPageFromSettings(TempData);
                List <Volunteer> volunteers = volunteerManager.GetListOfVolunteers();
                volunteers      = VolunteerFunctions.GetVolunteersAfterFilters(volunteers, searchedFullname, searchedContact, Active, HasCar, HasDrivingLicence, lowerdate, upperdate, gender, searchedAddress, searchedworkplace, searchedOccupation, searchedRemarks, searchedHourCount);
                ViewBag.counter = volunteers.Count();
                string stringofids = VolunteerFunctions.GetStringOfIds(volunteers);
                volunteers = VolunteerFunctions.GetVolunteerAfterPaging(volunteers, page, nrofdocs);
                volunteers = VolunteerFunctions.GetVolunteerAfterSorting(volunteers, sortOrder);
                string key = VolMongoConstants.SESSION_KEY_VOLUNTEER;
                HttpContext.Session.SetString(key, stringofids);

                if (HasDrivingLicence == true)
                {
                    ViewBag.Filter1 = "";
                }
                if (searchedFullname != null)
                {
                    ViewBag.Filters2 = searchedFullname;
                }
                if (searchedContact != null)
                {
                    ViewBag.Filter3 = searchedContact;
                }
                if (gender != null)
                {
                    ViewBag.Filter5 = gender;
                }
                if (searchedAddress != null)
                {
                    ViewBag.Filter6 = searchedAddress;
                }
                if (searchedworkplace != null)
                {
                    ViewBag.Filter7 = searchedworkplace;
                }
                if (searchedRemarks != null)
                {
                    ViewBag.Filter8 = searchedRemarks;
                }
                if (searchedOccupation != null)
                {
                    ViewBag.Filter9 = searchedOccupation;
                }
                if (searchedHourCount != 0)
                {
                    ViewBag.Filter10 = searchedHourCount.ToString();
                }
                if (Active != false)
                {
                    ViewBag.Filter11 = "";
                }
                if (HasCar != false)
                {
                    ViewBag.Filter12 = "";
                }
                DateTime date = Convert.ToDateTime("01.01.0001 00:00:00");
                if (lowerdate != date)
                {
                    ViewBag.Filter13 = lowerdate.ToString();
                }
                if (upperdate != date)
                {
                    ViewBag.Filter14 = upperdate.ToString();
                }
                ViewBag.page             = UniversalFunctions.GetCurrentPage(page);
                ViewBag.searchedFullname = searchedFullname;
                ViewBag.active           = Active;
                ViewBag.ContactInfo      = searchedContact;
                ViewBag.SortOrder        = sortOrder;
                ViewBag.Address          = searchedAddress;
                ViewBag.Occupation       = searchedOccupation;
                ViewBag.Remarks          = searchedRemarks;
                ViewBag.HourCount        = searchedHourCount;
                ViewBag.Upperdate        = upperdate;
                ViewBag.Lowerdate        = lowerdate;
                ViewBag.Gender           = gender;
                ViewBag.hascar           = HasCar;
                ViewBag.DesiredWorkplace = searchedworkplace;
                ViewBag.hasDriverLicence = HasDrivingLicence;
                ViewBag.NameSortParm     = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
                ViewBag.DateSortParm     = sortOrder == "Date" ? "date_desc" : "Date";
                ViewBag.FullnameSort     = sortOrder == "Fullname" ? "Fullname_desc" : "Fullname";
                ViewBag.HourCountSort    = sortOrder == "Hourcount" ? "Hourcount_desc" : "Hourcount";
                ViewBag.Gendersort       = sortOrder == "Gender" ? "Gender_desc" : "Gender";
                ViewBag.Activesort       = sortOrder == "Active" ? "Active_desc" : "Active";
                ViewBag.nrofdocs         = nrofdocs;

                return(View(volunteers));
            }
            catch
            {
                return(RedirectToAction("Localserver", "Home"));
            }
        }