public WarriorViewModel(IWarrior warrior) { if (warrior == null) { throw new ArgumentNullException("Warrior is null"); } Warrior = warrior; Warrior.PropertiesChanged += Warrior_PropertiesChanged; ShowWeaponsPickerCommand = new ShowWeaponsPicker(this); BuyWarriorCommand = new BuyWarrior(this); RemoveWarriorCommand = new RemoveWarrior(this); IncreaseWarriorBuyAmountCommand = new IncreaseBuyAmount(this); DecreaseWarriorBuyAmountCommand = new DecreaseBuyAmount(this); ShowSkillSelectorCommand = new ShowSkillSelector(this); foreach (IEquipment item in warrior.Equipment) { EquippedWeapons.Add(new EquipmentSummaryViewModel(item)); } foreach (var item in warrior.AllowedSkills) { //if (!warrior.Skills.Contains(item)) //{ AllowedSkills.Add(new SkillViewModel(item)); //} } IWizard wizard = warrior as IWizard; if (wizard != null) { foreach (var item in wizard.DrawnSpells) { Spells.Add(new SpellViewModel(item)); } } IHero hero = warrior as IHero; if (hero != null) { foreach (var item in hero.Injuries) { InjuryViewModel injuryModel = new InjuryViewModel(item); Injuries.Add(injuryModel); InjuriesSimple.Add(injuryModel); } foreach (var item in hero.Skills) { Skills.Add(new SkillViewModel(item)); SkillsSimple.Add(new SkillViewModelSimple(item)); } } }
public async Task <ActionResult> GetInjuryInfo() { InjuryViewModel[] injury = null; InjuryViewModel pain = null; List <InjuryViewModel> injuries = new List <InjuryViewModel>(); var thisClient = db.Clients.Include(c => c.ApplicationUser).Where(c => c.ApplicationId == userId).SingleOrDefault(); var pref = db.ClientPrefs.Include(p => p.Client.ApplicationUser).Where(p => p.ClientId == thisClient.Id).SingleOrDefault(); HttpClient client = new HttpClient(); string url = "https://localhost:44333/api/Injuries"; HttpResponseMessage response = await client.GetAsync(url); string jsonResult = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { injury = JsonConvert.DeserializeObject <InjuryViewModel[]>(jsonResult); foreach (var item in injury) { if ((pref.HeadPain == true || pref.NeckPain == true) && item.InjuryLocation == "Head") { injuries.Add(item); } else if ((pref.ShoulderPain == true || pref.ArmPain == true || pref.WristHandPain == true) && item.InjuryLocation == "Arm") { injuries.Add(item); } else if ((pref.UpperBackPain == true || pref.LowBackPain == true) && item.InjuryLocation == "Back") { injuries.Add(item); } else if ((pref.HipPain == true) && item.InjuryLocation == "Hip") { injuries.Add(item); } else if ((pref.ThighPain == true || pref.KneeLegPain == true || pref.AnkleFootPain == true) && item.InjuryLocation == "Leg") { injuries.Add(item); } } } return(View("Injury", injuries)); }