public NameSearchResult PageNameSearchForTitles(string name, string languageCode) { CustomGenericList<CustomDataRow> data = GetPageNameDalInstance().PageNameSearchForTitles(null, null, name, languageCode); NameSearchResult result = new NameSearchResult(); result.QueryDate = DateTime.Now.ToString("dd MMM yyyy h:mmtt"); //loop through the results and create a list of NameSearchTitle objects foreach (CustomDataRow row in data) { NameSearchTitle title = new NameSearchTitle(); title.TitleID = (int)row["TitleID"].Value; title.ShortTitle = (string)row["ShortTitle"].Value + " " + (string)row["PartNumber"].Value + " " + (string)row["PartName"].Value; title.SortTitle = (string)row["SortTitle"].Value; title.MarcBibID = (string)row["MarcBibID"].Value; title.TotalPageCount = (int)row["TotalPageCount"].Value; result.Titles.Add(title); } return result; }
private NameSearchResult GetPageNameSearchResult(CustomGenericList<CustomDataRow> data) { NameSearchResult result = new NameSearchResult(); result.QueryDate = DateTime.Now.ToString("dd MMM yyyy h:mmtt"); //loop through the results and create a list of NameSearchTitle objects int lastTitleID = -1; int lastItemID = -1; //List<NameSearchTitle> titleList = new List<NameSearchTitle>(); foreach (CustomDataRow row in data) { int currentTitleID = (int)row["TitleID"].Value; if (currentTitleID != lastTitleID) { NameSearchTitle title = new NameSearchTitle(); title.TitleID = (int)row["TitleID"].Value; title.ShortTitle = (string)row["ShortTitle"].Value; title.SortTitle = (string)row["SortTitle"].Value; title.MarcBibID = (string)row["MarcBibID"].Value; result.Titles.Add(title); } NameSearchTitle currentTitle = result.Titles[result.Titles.Count - 1]; int currentItemID = (int)row["ItemID"].Value; if (currentItemID != lastItemID) { NameSearchItem item = new NameSearchItem(); item.ItemID = (int)row["ItemID"].Value; item.ItemSequence = (short)row["ItemSequence"].Value; item.Volume = (string)row["ItemVolume"].Value; currentTitle.Items.Add(item); } NameSearchItem currentItem = currentTitle.Items[currentTitle.Items.Count - 1]; NameSearchPage page = new NameSearchPage(); page.PageID = (int)row["PageID"].Value; page.SequenceOrder = (int)row["SequenceOrder"].Value; page.IndicatedPages = (string)row["IndicatedPages"].Value; currentTitle.TotalPageCount++; currentItem.Pages.Add(page); lastTitleID = currentTitleID; lastItemID = currentItemID; } return result; }