/// <summary> /// Searches the items. /// </summary> /// <param name="argQueryString"> /// The query string. /// </param> /// <returns> /// List of Serch HLinks. /// </returns> public override HLinkPersonModelCollection Search(string argQuery) { HLinkPersonModelCollection itemsFound = new HLinkPersonModelCollection { Title = "People" }; if (string.IsNullOrEmpty(argQuery)) { return(itemsFound); } // Get list of peoples names HLinkPersonNameModelCollection tt = DV.PersonNameDV.Search(argQuery); // Convert to HLinkPersonModels List <HLinkPersonModel> ttt = new List <HLinkPersonModel>(); foreach (var item in tt) { foreach (HLinkBackLink item1 in item.DeRef.BackHLinkReferenceCollection) { if (item1.HLinkType == HLinkBackLink.HLinkBackLinkEnum.HLinkPersonModel) { ttt.Add(item1.HLink as HLinkPersonModel); } } } // Get Distinct foreach (var item2 in ttt.Distinct()) { itemsFound.Add(item2); } return(itemsFound); }
private HLinkPersonNameModelCollection GetPersonNameCollection(XElement xmlData) { HLinkPersonNameModelCollection t = new HLinkPersonNameModelCollection(); var theERElement = from orElementEl in xmlData.Elements(ns + "name") select orElementEl; if (theERElement.Any()) { // Load attribute object references foreach (XElement theLoadORElement in theERElement) { // TODO is date handling correct PersonNameModel newPersonNameModel = new PersonNameModel { Handle = "PersonNameCollection", GCitationRefCollection = GetCitationCollection(theLoadORElement), GDate = SetDate(theLoadORElement), GDisplay = GetElement(theLoadORElement, "display"), GFamilyNick = GetElement(theLoadORElement, "familynick"), GFirstName = GetElement(theLoadORElement, "first"), GGroup = GetElement(theLoadORElement, "group"), GNick = GetElement(theLoadORElement, "nick"), GPriv = SetPrivateObject(GetAttribute(theLoadORElement.Attribute("priv"))), GSort = GetElement(theLoadORElement, "sort"), GSuffix = GetElement(theLoadORElement, "suffix"), GSurName = GetSurnameCollection(theLoadORElement), GTitle = GetElement(theLoadORElement, "title"), GType = GetAttribute(theLoadORElement.Attribute("type")), GNoteReferenceCollection = GetNoteCollection(theLoadORElement), }; newPersonNameModel.GAlt.SetAlt(GetAttribute(theLoadORElement, "alt")); // Set model hlinkkey newPersonNameModel.HLinkKey = Guid.NewGuid().ToString(); DataStore.DS.PersonNameData.Add(newPersonNameModel); // Create a HLink to the model HLinkPersonNameModel newHlink = new HLinkPersonNameModel { HLinkKey = newPersonNameModel.HLinkKey }; t.Add(newHlink); } } // Do not sort as the source file order is the one the creator wanted return(t); }
private HLinkPersonNameModelCollection GetPersonNameCollection(XElement xmlData) { HLinkPersonNameModelCollection t = new HLinkPersonNameModelCollection { Title = "Person Name Collection" }; var theERElement = from orElementEl in xmlData.Elements(ns + "name") select orElementEl; if (theERElement.Any()) { // Load attribute object references foreach (XElement theLoadORElement in theERElement) { // TODO is date handling correct PersonNameModel newPersonNameModel = new PersonNameModel { GCitationRefCollection = GetCitationCollection(theLoadORElement), GDate = SetDate(theLoadORElement), GDisplay = GetElement(theLoadORElement, "display"), GFamilyNick = GetElement(theLoadORElement, "familynick"), GFirstName = GetElement(theLoadORElement, "first"), GGroup = GetElement(theLoadORElement, "group"), GNick = GetElement(theLoadORElement, "nick"), Priv = GetPrivateObject(theLoadORElement), GSort = GetElement(theLoadORElement, "sort"), GSuffix = GetElement(theLoadORElement, "suffix"), GSurName = GetSurnameCollection(theLoadORElement), GTitle = GetElement(theLoadORElement, "title"), GType = GetAttribute(theLoadORElement.Attribute("type")), GNoteReferenceCollection = GetNoteCollection(theLoadORElement), }; newPersonNameModel.GAlt = new AltModel(GetAttribute(theLoadORElement, "alt")); newPersonNameModel.HLinkKey = HLinkKey.NewAsGUID(); DataStore.Instance.DS.PersonNameData.Add(newPersonNameModel); //var tt = (DataStore.Instance.DS.PersonNameData.Where(x => x.Value.GSurName.GetPrimarySurname == "Ainger")); //if (tt.Count() > 0) //{ //} // Create a HLink to the model HLinkPersonNameModel newHlink = new HLinkPersonNameModel { HLinkKey = newPersonNameModel.HLinkKey }; t.Add(newHlink); } } // Do not sort as the source file order is the one the creator wanted return(t); }