private void PopulateIntializeView(BrowseFormModel browseFormModel) { InterviewerListBox.ItemsSource = browseFormModel.InterviewerList; SubjectListBox.ItemsSource = browseFormModel.SubjectList; ContentDMListBox.ItemsSource = browseFormModel.ContentDmList; DarkArchiveListBox.ItemsSource = browseFormModel.RestrictionList; }
private BrowseFormModel GetFilterBoxes(IEnumerable <transcription> transcriptions) { BrowseFormModel browseFormModel = new BrowseFormModel(); // Interview list List <string> interviewerList = new List <string>(); List <string> subjectList = new List <string>(); foreach (transcription item in transcriptions) { List <string> words = item.Interviewer.Split(';').Select(p => p.Trim()).ToList(); foreach (string word in words) { if (!string.IsNullOrEmpty(word)) { interviewerList.Add(word); } } string[] subjects = item.Subject.Split(';'); foreach (string word in subjects) { if (!string.IsNullOrEmpty(word)) { subjectList.Add(word); } } } var interviewers = from x in interviewerList group x by x into g let count = g.Count() orderby count descending select new { Value = g.Key, Count = count }; foreach (var interviewer in interviewers) { browseFormModel.InterviewerList.Add(BrowseFormModel.SetListBoxItem(interviewer.Value.Trim(), interviewer.Count, Request.TranscriptionSearchModel.Interviewers)); } var subjectsList = from x in subjectList group x by x into g let count = g.Count() orderby count descending select new { Value = g.Key.Trim(), Count = count }; foreach (var subject in subjectsList) { browseFormModel.SubjectList.Add(BrowseFormModel.SetListBoxItem(subject.Value.Trim(), subject.Count, Request.TranscriptionSearchModel.Subjects)); } //Content DM list var contentDMs = transcriptions .GroupBy(n => n.IsOnline) .Select(n => new { IsOnline = n.Key, Count = n.Count() }); List <KeyValuePair <string, string> > contentDMList = new List <KeyValuePair <string, string> >(); foreach (var item in contentDMs) { browseFormModel.ContentDmList.Add(BrowseFormModel.SetListBoxItem(item.IsOnline.ToString(), item.Count, Request.TranscriptionSearchModel.Contentdms)); } // Dark Archieve List ListBoxItem restriction = browseFormModel.RestrictionList.First(); restriction.Name = Request.TranscriptionSearchModel.IsDarkArchived ? BrowseFormModel.DarkArchive : BrowseFormModel.NotDarkArchive; restriction.IsChecked = Request.TranscriptionSearchModel.IsDarkArchived; restriction.Count = transcriptions.Count(); return(browseFormModel); }
/// <summary> /// The actual Work to be done. /// </summary> protected override void Execute() { BrowseFormModel browseFormModel = new BrowseFormModel(); IQueryable <transcription> transcriptions = null; if (Request.IsAdminUser) { transcriptions = TranscriptionRepository.GetAll(); } else { transcriptions = TranscriptionRepository.FindBy(p => !p.IsRestriction); } // Interview list //List<string> interviewerList = new List<string>(); //foreach (transcription item in transcriptions) //{ // List<string> words = item.Interviewer.Split(';').Select(p => p.Trim()).ToList(); // foreach (string word in words) // { // if (!string.IsNullOrEmpty(word)) // { // interviewerList.Add(word); // } // } //} //var interviewers = from x in interviewerList // group x by x into g // let count = g.Count() // orderby count descending // select new { Value = g.Key, Count = count }; //foreach (var interviewer in interviewers) //{ // browseFormModel.InterviewerList.Add(SetPair(interviewer.Value, interviewer.Count)); //} //Collection list var collections = transcriptions .GroupBy(n => n.CollectionId) .Select(n => new { CollectionId = n.Key, Count = n.Count() }); List <collection> daCollections = CollectionRepository.GetCollections(); foreach (var item in collections) { collection collectionOjb = daCollections.First(c => c.Id == item.CollectionId); browseFormModel.CollectionList.Add(SetListBoxItem(collectionOjb.CollectionName, item.Count, collectionOjb.Id)); } // Subseries List //var subserieList = transcriptions // .GroupBy(n => n.SubseriesId) // .Select(n => new // { // SubseriesId = n.Key, // Count = n.Count() // }); //List<subsery> subseries = SubseryRepository.GetAll().ToList(); //foreach (var item in subserieList) //{ // subsery subseryObj = subseries.First(c => c.Id == item.SubseriesId); // if (subseryObj.SubseriesName.Trim() != "N/A") // { // browseFormModel.SubseriesList.Add(SetListBoxItem(subseryObj.SubseriesName, item.Count, subseryObj.Id)); // } //} ////Content DM list //var contentDMs = transcriptions // .GroupBy(n => n.IsOnline) // .Select(n => new // { // IsOnline = n.Key, // Count = n.Count() // }); //List<KeyValuePair<string, string>> contentDMList = new List<KeyValuePair<string, string>>(); //foreach (var item in contentDMs) //{ // browseFormModel.ContentDmList.Add( // new KeyValuePair<string, string>( // item.IsOnline.ToString() + " (" + item.Count + ")", item.IsOnline.ToString())); //} //// Subject list //List<string> subjectList = new List<string>(); //foreach (transcription item in transcriptions) //{ // string[] words = item.Subject.Split(';'); // foreach (string word in words) // { // if (!string.IsNullOrEmpty(word)) // { // subjectList.Add(word); // } // } //} //var subjects = from x in subjectList // group x by x into g // let count = g.Count() // orderby count descending // select new { Value = g.Key, Count = count }; //foreach (var subject in subjects) //{ // browseFormModel.SubjectList.Add(SetPair(subject.Value, subject.Count)); //} Response = new ResponseModel() { BrowseFormModel = browseFormModel, IsOperationSuccess = true }; }