/// <summary> /// Function that returns a list of NpcId and NpcName from a list of NpcIds. /// </summary> /// <param name="ListOfNumbers"> This is the list from which the children is collected.</param> /// <returns></returns> static List <NpcListViewModel> GatherTheChildren(List <int> ListOfNumbers) { SerdanDb Db = new SerdanDb(); List <NpcListViewModel> childList = new List <NpcListViewModel>(); for (int i = 0; i < ListOfNumbers.Capacity; i++) { NPC Child = Db.NPCs.SingleOrDefault(n => n.NpcId == ListOfNumbers[i]); NpcListViewModel compactChild = new NpcListViewModel { NpcId = Child.NpcId, NpcName = Child.NpcName }; childList.Add(compactChild); } return(childList); }
internal static NpcRelativesViewModel AssignRelativesData(NPC NpcToAssign) { SerdanDb Db = new SerdanDb(); NPC NpcFather = Db.NPCs.SingleOrDefault(n => n.NpcId == NpcToAssign.NpcsFather); NPC NpcMother = Db.NPCs.SingleOrDefault(n => n.NpcId == NpcToAssign.NpcsMother); NpcRelativesViewModel FilteredNpc = new NpcRelativesViewModel { NpcId = NpcToAssign.NpcId, NpcsFather = NpcFather == null ? "Okänd." : NpcFather.NpcName, NpcsFatherId = NpcFather == null ? 0 : NpcFather.NpcId, NpcsMother = NpcMother == null ? "Okänd." : NpcMother.NpcName, NpcsMotherId = NpcMother == null ? 0: NpcMother.NpcId, NpcsRegularChildren = GatherTheChildren(NpcToAssign.NpcsRegularChildren), NpcsSerdanEdlosiChildren = GatherTheChildren(NpcToAssign.NpcsSerdanEdlosiChildren) }; return(FilteredNpc); }
public NPCController() { Db = new SerdanDb(); }