/// <summary> /// Gets the encounters and items by instance identifier. /// </summary> /// <param name="instanceModel">The instance model.</param> /// <returns> /// The encounters for the dungeon. /// </returns> public async Task <List <EncounterModel> > GetEncountersAndItemsByInstanceId(int instanceId) { List <EncounterModel> encModels = new List <EncounterModel>(); //On récupère les instances name grâce à la fct getInstanceById var resInstance = await InstanceRepoAPI.GetInstanceById(staticNamespace, localeUS, instanceId); var resEnc = await EncounterRepoAPI.SearchEncounter(staticNamespace, locale, resInstance.name); if (resEnc != null) { foreach (ResultEncounter result in resEnc.results) { EncounterModel encModel = new EncounterModel() { Id = result.data.id, Name = result.data.name.fr_FR, IdInstance = result.data.instance.id, Items = await GetItemsByID(result.data.items.Select(i => i.item.id).ToList()), }; int idMedia = result.data.creatures[0].creature_display.id; var resMediaCreature = await ItemRepoAPI.GetMediaCreatureById(staticNamespace, localeUS, idMedia); encModel.Media = resMediaCreature?.assets[0]?.value; encModels.Add(encModel); } } return(encModels); }
public async Task <List <EncounterModel> > GetEncountersByInstanceId(int idInstance, List <int> idItems) { List <EncounterModel> encModels = new List <EncounterModel>(); //On récupère les instances name grâce à la fct getInstanceById var resInstance = await InstanceRepoAPI.GetInstanceById(staticNamespace, localeUS, idInstance); var resEnc = await EncounterRepoAPI.SearchEncounter(staticNamespace, locale, resInstance.name); if (resEnc != null) { foreach (ResultEncounter result in resEnc.results) { EncounterModel encModel = new EncounterModel(); encModel.Id = result.data.id; encModel.Name = result.data.name.fr_FR; encModel.IdInstance = result.data.instance.id; encModel.IdItems = new List <int>(); int idMedia = result.data.creatures[0].creature_display.id; var resMediaCreature = await ItemRepoAPI.GetMediaCreatureById(staticNamespace, localeUS, idMedia); encModel.Media = resMediaCreature.assets[0].value; foreach (var item in result.data.items) { encModel.IdItems.Add(item.item.id); //Je remplis une liste d'idItems récupérée de l'extérieur pour pouvoir //remplir ma table ITEM indépendamment des boss (récupérer tous les id dans une liste, //Enlever les doublons, récupérer les ITEMMODEL avec "GetItemsByID" et les insérer dans la db" idItems.Add(item.item.id); } encModels.Add(encModel); } } return(encModels); }