public void Initialize()
        {
            DbContextHelpers contextHelpers = new DbContextHelpers();
            search = new ExerciseSearch();

            db = contextHelpers.getDbContext();
            adminCon = new AdminExercisesController(db.Object)
            {
                // sign in as admin
                ControllerContext = MockContext.AuthenticationContext("admin")
            };
        }
        /// <summary>
        /// Sets the session search parameters based on the current search values
        /// </summary>
        /// <param name="search">The WorkoutSearch object containing the values to set in the session</param>
        private void setSessionFromSearch(ExerciseSearch search)
        {
            if (Session != null)
            {
                if (!String.IsNullOrEmpty(search.name)) Session["NameSearchParam"] = search.name;
                else Session["NameSearchParam"] = "";

                if (!String.IsNullOrEmpty(search.description)) Session["DescriptionSearchParam"] = search.description;
                else Session["DescriptionSearchParam"] = "";

            }
        }
 /// <summary>
 /// Sets the WorkoutSearch object with the stored session search variables if they exist
 /// </summary>
 /// <param name="search">The WorkoutSearch object to set</param>
 /// <returns>The WorkoutSearch object set with the session search variables if the session exists, else the passed in WorkoutSearch object</returns>
 private ExerciseSearch setSearchFromSession(ExerciseSearch search)
 {
     if (Session != null)
     {
         search.name = Session["NameSearchParam"] as String;
         search.description = Session["DescriptionSearchParam"] as String;
     }
     return search;
 }
        /// <summary>
        /// Private helper method to perform a new search or maintain a previous search through 
        /// pagination and filter changes
        /// </summary>
        /// <param name="workouts">The base workout query result</param>
        /// <param name="sortBy">The passed sort string if it exists, else null</param>
        /// <param name="page">The passed page param if it exists, else null</param>
        /// <returns>The searched workouts</returns>
        private IQueryable<exercise> doSearch(IQueryable<exercise> categories, ExerciseSearch search, String filterString, string sortBy, int? page)
        {
            if (page != null || !String.IsNullOrEmpty(sortBy) || !String.IsNullOrEmpty(filterString))
            {
                search = setSearchFromSession(search);
            }
            else setSessionFromSearch(search);

            if (!String.IsNullOrEmpty(search.name)) categories = categories.Where(c => c.name.Contains(search.name));
            if (!String.IsNullOrEmpty(search.description)) categories = categories.Where(c => c.description.Contains(search.description));

            return categories;
        }
        // GET: AdminExercises
        public ActionResult Index(string filterString, string sortBy, int? page, ExerciseSearch exerciseSearch)
        {
            var exercises = from e in db.exercises select e;
            exercises = this.doSearch(exercises, exerciseSearch, filterString, sortBy, page);
            exercises = this.doSort(exercises, sortBy);

            int pageNumber = (page ?? 1);
            var view = View("Index", exercises.ToPagedList(pageNumber, pageSize));
            return view;
        }