private static void AssignProfileId(DocumentsGridModel model, string profileId, IList<ProfileDetails> userProfiles)
 {
     // If request params don't have any selected profile, use the first profile to populate the model
     model.ProfileId = profileId == null
         ? userProfiles[0].Id
         : int.Parse(profileId);
 }
        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);
            return View(model);
        }
 private void GetDocumentItems(DocumentsGridModel model)
 {
     model.DocumentItems = _reader.GetDocuments(model.ProfileId);
 }
        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;
        }