public ActionResult Index()
        {
            var profileId = Request.Params["selectedProfile"];
            var model     = new DocumentsGridModel
            {
                SortBy           = "Sequence",
                SortAscending    = true,
                CurrentPageIndex = 1,
                PageSize         = 100
            };

            var user         = UserDetails.CurrentUser();
            var userProfiles = user.GetProfilesUserHasPermissionsTo().ToList();

            AssignProfileList(model, userProfiles);
            AssignProfileId(model, profileId, userProfiles);

            GetDocumentItems(model);



            //  Session["GetAllProfile"] = model.ProfileList;

            //ViewBag.GetAllProfile = model;

            return(View(model));
        }
        private void AssignProfileList(DocumentsGridModel model, IList <ProfileDetails> profilesDetails)
        {
            IEnumerable <SelectListItem> userProfilesForModel = profilesDetails.Select(c => new SelectListItem
            {
                Text  = c.Name.ToString(CultureInfo.InvariantCulture),
                Value = c.Id.ToString(CultureInfo.InvariantCulture)
            });

            model.ProfileList = userProfilesForModel;
        }
 private static void AssignProfileId(DocumentsGridModel model, string profileId,
                                     IList <ProfileDetails> profilesThatUserCanEdit)
 {
     // If request params don't have any selected profile, use the first profile to populate the model
     if (profilesThatUserCanEdit.Count > 0)
     {
         model.ProfileId = profileId == null
             ? profilesThatUserCanEdit[0].Id
             : int.Parse(profileId);
     }
 }
 private void GetDocumentItems(DocumentsGridModel model)
 {
     model.DocumentItems = _reader.GetDocuments(model.ProfileId);
 }