public IActionResult GetNpcs(string race) { ViewBag.Title = race; //List<NPC> ListOfNPCs = ISerdan.GetMultipleNPCs(race); List <NPC> RequestedTypeOfNPCs = new List <NPC>(); List <NpcGeneralViewModel> ConvertedNpcData = new List <NpcGeneralViewModel>(); NpcGeneralViewModel aConvertedNpc = new NpcGeneralViewModel(); //foreach (var NPC in ListOfNPCs) //{ // if (NPC.NpcRace == race) // { // RequestedTypeOfNPCs.Add(NPC); // } //} foreach (var NPC in RequestedTypeOfNPCs) { aConvertedNpc.NpcId = NPC.NpcId; aConvertedNpc.NpcName = NPC.NpcName; ConvertedNpcData.Add(aConvertedNpc); } return(PartialView("_GetNpcList", ConvertedNpcData)); }
public ActionResult GetNpc([Bind(Include = "Id")] int Id) { NPC selectedNpc = Db.NPCs.SingleOrDefault(i => i.NpcId == Id); NpcGeneralViewModel ASpecificNpcData = new NpcGeneralViewModel { NpcId = selectedNpc.NpcId, NpcName = selectedNpc.NpcName, NpcEvenKnownAs = selectedNpc.NpcEvenKnownAs, NpcAlias = selectedNpc.NpcAlias, NpcDescriptivePhrase = selectedNpc.NpcDescriptivePhrase, NpcArchetyp = selectedNpc.NpcArchetyp, NpcCurrentResidence = selectedNpc.NpcCurrentResidence, NpcDescription = selectedNpc.NpcDescription, NpcFamily = selectedNpc.NpcFamily, NpcKilledBy = selectedNpc.NpcKilledBy, NpcLooks = selectedNpc.NpcLooks }; return(PartialView("_SpecificNpc", ASpecificNpcData)); }
public ActionResult GetNpcs([Bind(Include = "race")] string race) { ViewBag.Title = race; List <NPC> ListOfNPCs = Db.NPCs.ToList(); List <NPC> RequestedTypeOfNPCs = new List <NPC>(); List <NpcGeneralViewModel> ConvertedNpcData = new List <NpcGeneralViewModel>(); NpcGeneralViewModel aConvertedNpc = new NpcGeneralViewModel(); foreach (var NPC in ListOfNPCs) { if (NPC.NpcRace == race) { RequestedTypeOfNPCs.Add(NPC); } } foreach (var NPC in RequestedTypeOfNPCs) { aConvertedNpc.NpcId = NPC.NpcId; aConvertedNpc.NpcName = NPC.NpcName; ConvertedNpcData.Add(aConvertedNpc); } return(PartialView("_GetNpcList", ConvertedNpcData)); }