public ActionResult Folders() { var employer = CurrentEmployer; // Treat the flag list as a special folder. var flagList = _candidateFlagListsQuery.GetFlagList(employer); var count = _candidateFlagListsQuery.GetFlaggedCount(employer); // Get the folders and their counts. var folders = _candidateFoldersQuery.GetFolders(employer); var counts = _candidateFoldersQuery.GetInFolderCounts(employer); var lastUsedTimes = _candidateFoldersQuery.GetLastUsedTimes(employer); var flagListModels = flagList == null ? new FolderModel[0] : new [] { new FolderModel { Id = flagList.Id, Name = null, Type = flagList.FlagListType.ToString(), CanDelete = false, CanRename = false, Count = count } }; var folderModels = folders .OrderBy(f => f, new FolderComparer(lastUsedTimes)) .Select(f => new FolderModel { Id = f.Id, Name = f.Name, Type = f.FolderType.ToString(), CanDelete = _candidateFoldersCommand.CanDeleteFolder(employer, f), CanRename = _candidateFoldersCommand.CanRenameFolder(employer, f), Count = GetCount(f.Id, counts), }); return(Json(new JsonFoldersModel { Folders = flagListModels.Concat(folderModels).ToList() })); }
public ActionResult Folders() { var employer = CurrentEmployer; // Get the folders and their counts. var folderData = new Dictionary <Guid, FolderDataModel>(); // Flag list. var flagList = _candidateFlagListsQuery.GetFlagList(employer); var count = _candidateFlagListsQuery.GetFlaggedCount(employer); folderData[flagList.Id] = new FolderDataModel { Count = count, CanDelete = false, CanRename = false }; // Folders. var folders = _candidateFoldersQuery.GetFolders(employer); var counts = _candidateFoldersQuery.GetInFolderCounts(employer); var lastUsedTimes = _candidateFoldersQuery.GetLastUsedTimes(employer); foreach (var folder in folders) { folderData[folder.Id] = new FolderDataModel { Count = GetCount(folder.Id, counts), CanRename = _candidateFoldersCommand.CanRenameFolder(employer, folder), CanDelete = _candidateFoldersCommand.CanDeleteFolder(employer, folder), }; } var comparer = new FolderComparer(lastUsedTimes); return(View(new FoldersModel { FlagList = flagList, ShortlistFolder = (from f in folders where f.FolderType == FolderType.Shortlist select f).SingleOrDefault(), PrivateFolders = (from f in folders where f.FolderType == FolderType.Private || f.FolderType == FolderType.Mobile select f).OrderBy(f => f, comparer).ToList(), SharedFolders = (from f in folders where f.FolderType == FolderType.Shared select f).OrderBy(f => f, comparer).ToList(), FolderData = folderData, })); }