public ActionResult ManageProfiles()
        {
            var model = new ProfileGridModel
            {
                SortBy = "Sequence",
                SortAscending = true,
                CurrentPageIndex = 1,
                PageSize = 200
            };

            GetAllProfiles(model);

            return View(model);
        }
 private void GetAllProfiles(ProfileGridModel model)
 {
     model.ProfileGrid = _reader.GetProfiles().OrderBy(x => x.Name).ToList();
 }
        public ActionResult SortProfilesAndFilter(string sortBy = "Id",
            bool ascending = true, int page = 1, int pageSize = 200)
        {
            var model = new ProfileGridModel
            {
                SortBy = sortBy,
                SortAscending = @ascending,
                CurrentPageIndex = page,
                PageSize = pageSize
            };

            //Get all the profiles
            GetAllProfiles(model);
            IList<ProfileDetails> sortedProfiles = null;

            if (ascending)
            {
                switch (sortBy)
                {
                    case "Id":
                        sortedProfiles = model.ProfileGrid.OrderBy(x => x.Id).ToList();
                        break;
                    case "Url_Key":
                        sortedProfiles = model.ProfileGrid.OrderBy(x => x.UrlKey).ToList();
                        break;
                }
            }
            else
            {
                switch (sortBy)
                {
                    case "Id":
                        sortedProfiles = model.ProfileGrid.OrderByDescending(x => x.Id).ToList();
                        break;
                    case "Url_Key":
                        sortedProfiles = model.ProfileGrid.OrderByDescending(x => x.UrlKey).ToList();
                        break;
                }
            }

            model.ProfileGrid = sortedProfiles;

            return View("ManageProfiles", model);
        }