public SkillAbilityTypes insert(int skillId, int abilityTypeId, out bool success) { skillAbilityType = new SkillAbilityTypes(); using (Dota2Entities ctx = new Dota2Entities()) { try { skillAbilityType.SkillId = skillId; skillAbilityType.AbilityTypeId = abilityTypeId; ctx.SkillAbilityTypes.Add(skillAbilityType); ctx.SaveChanges(); success = true; } catch (Exception e) { success = false; throw e; } } return skillAbilityType; }
public SkillEffectName insertSkillEffectName(string name, string heroName, string skillName, List<string> skillEffectValues, string skillDescription) { SkillEffectName skillEffectName = new SkillEffectName(); Skill skill = SkillCreator.SelectByName(skillName); skillEffectName.Name = name.Trim(); skillEffectName = checkIfSkillNameExists(name, skill, skillDescription); if (skillEffectName == null) { using (Dota2Entities ctx = new Dota2Entities()) { try { skillEffectName = ctx.SkillEffectName.Add(skillEffectName); ctx.SaveChanges(); Console.WriteLine("Skill " + name + " Created"); } catch (Exception e) { throw e; } } } return skillEffectName; }
public SkillEffectName InsertSkillEffectName(string name, string heroName, Skill skill, List<string> skillEffectValues) { SkillEffectName skillEffectName; Skill completeSkill = SkillCreator.SelectByName(skill.Name); bool exists = checkIfSkillNameExists(name, completeSkill, completeSkill.Description, out skillEffectName); if (!exists) { skillEffectName.Name = name.Trim(); skillEffectName.SkillId = completeSkill.ID; skillEffectName.ValueLv1 = int.Parse(skillEffectValues.First()); skillEffectName.ValueLv2 = int.Parse(skillEffectValues.ElementAt(1)); skillEffectName.ValueLv3 = int.Parse(skillEffectValues.ElementAt(2)); skillEffectName.ValueLv4 = int.Parse(skillEffectValues.ElementAt(3)); skillEffectName.ValueScepter = int.Parse(skillEffectValues.Last()); using (Dota2Entities ctx = new Dota2Entities()) { try { skillEffectName = ctx.SkillEffectName.Add(skillEffectName); ctx.SaveChanges(); Console.WriteLine("Skill " + name + " Created"); } catch (Exception e) { throw e; } } } return skillEffectName; }
public SkillImage InsertSkillImage(int skillId, string imageUrl) { SkillImage skillImage = new SkillImage(); try { using (Dota2Entities ctx = new Dota2Entities()) { //Check if the image exists if (!ctx.SkillImage.Any(si => si.Url == imageUrl)) { skillImage.SkillId = skillId; skillImage.Url = imageUrl; ctx.SkillImage.Add(skillImage); ctx.SaveChanges(); } else { skillImage = ctx.SkillImage.Where(si => si.Url == imageUrl).FirstOrDefault(); Console.WriteLine("SkillImage Already exists"); } } } catch (Exception) { //TODO implementar log throw; } return skillImage; }
public AttributesCreator(int heroId, Dictionary<string, string> primaryStats) { attribute = new Attributes(); attribute.HeroId = heroId; attribute.Intelligence = primaryStats["Intelligence"]; attribute.Agility = primaryStats["Agility"]; attribute.Strength = primaryStats["Strength"]; attribute.Damage = primaryStats["Damage"]; attribute.MoveSpeed = primaryStats["Movespeed"]; attribute.Armor = primaryStats["Armor"]; using (Dota2Entities ctx = new Dota2Entities()) { try { ctx.Attributes.Add(this.attribute); ctx.SaveChanges(); Console.WriteLine("Primary Stats Created "); } catch (Exception e) { //TODO Adicionar ao log throw e; } } }
public Hero createHero(string heroName, string biography) { this.hero = new Hero(); this.hero.Name = heroName; this.hero.Biography = biography; using (Dota2Entities ctx = new Dota2Entities()) { try { ctx.Hero.Add(this.hero); ctx.SaveChanges(); Console.WriteLine("*************************** " + heroName + " Created(Hero)" + "***************************"); } catch (Exception e) { //TODO Adicionar ao log throw e; } } return this.hero; }
public HeroPortrait InsertHeroPortrait(int heroId, string imageUrl) { HeroPortrait HeroPortrait = new HeroPortrait(); try { using (Dota2Entities ctx = new Dota2Entities()) { //Check if the image exists if (!ctx.HeroPortrait.Any(si => si.Url == imageUrl)) { HeroPortrait.HeroId = heroId; HeroPortrait.Url = imageUrl; ctx.HeroPortrait.Add(HeroPortrait); ctx.SaveChanges(); Console.WriteLine("Image " + HeroPortrait.Url + " Added"); } else { HeroPortrait = ctx.HeroPortrait.Where(si => si.Url == imageUrl).FirstOrDefault(); Console.WriteLine("HeroPortrait Already exists"); } } } catch (Exception) { //TODO implementar log throw; } return HeroPortrait; }
public Hero createHero(string name, List<string> primaryStats, string biography) { this.hero = new Hero(); this.hero.Name = name; this.hero.Biography = biography; using (Dota2Entities ctx = new Dota2Entities()) { try { ctx.Hero.Add(this.hero); ctx.SaveChanges(); } catch(Exception e) { //TODO Adicionar ao log throw e.Message; } return this.hero; } }
public SkillEffectName insertSkillEffectName(string name) { SkillEffectName skillEffectName = new SkillEffectName(); skillEffectName.Name = name.Trim(); using(Dota2Entities ctx = new Dota2Entities()) { try { skillEffectName = ctx.SkillEffectName.Add(skillEffectName); ctx.SaveChanges(); Console.WriteLine("Skill " + name + " Created"); } catch (Exception e) { throw e; } } return skillEffectName; }
/// <summary> /// Insert a new Skill and SkillAbilityTypes /// </summary> private Skill InsertSkill() { SkillAbilityTypesCreator skillAbilityTypesCreator = new SkillAbilityTypesCreator(); bool isSkillAbilityTypeInserted = false; using (Dota2Entities ctx = new Dota2Entities()) { try { ctx.Skill.Add(this.skill); ctx.SaveChanges(); foreach (var abilityType in abilityTypeList) { skillAbilityTypesCreator.insert(this.skill.ID, abilityType.ID, out isSkillAbilityTypeInserted); //If we have a error when inserting SkillAbilityType, then delete the inserted skill if(!isSkillAbilityTypeInserted) { //TODO Create a function to remove all the SkillAbilityTypes that have been created for this skill ctx.Skill.Remove(this.skill); } } } catch (Exception e) { //TODO Adicionar ao log throw e; } } return this.skill; }
/// <summary> /// Insert a new Skill and SkillAbilityTypes /// </summary> Skill insertSkill() { SkillAbilityTypesCreator skillAbilityTypesCreator = new SkillAbilityTypesCreator(); using (Dota2Entities ctx = new Dota2Entities()) { try { ctx.Skill.Add(this.skill); foreach (var abilityType in abilityTypeList) { skillAbilityTypesCreator.insert(this.skill.ID, abilityType.ID); } ctx.SaveChanges(); } catch (Exception e) { //TODO Adicionar ao log throw e; } } return this.skill; }
public SkillEffectName InsertSkillEffectName(string name, string heroName, Skill skill, List<string> skillEffectValues) { HeroCreator heroCreator = new HeroCreator(); SkillEffectName skillEffectName; Hero hero = heroCreator.getHeroByName(heroName); Skill completeSkill = SkillCreator.SelectSkill(skill.Name, hero.ID); bool exists = checkIfSkillNameExists(name, completeSkill, completeSkill.Description, out skillEffectName); if (!exists) { skillEffectName.Name = name.Trim(); skillEffectName.SkillId = completeSkill.ID; if (skillEffectValues.FirstOrDefault() != null) skillEffectName.ValueLv1 = skillEffectValues.First(); if (skillEffectValues.ElementAtOrDefault(1) != null) skillEffectName.ValueLv2 = skillEffectValues.ElementAt(1); if (skillEffectValues.ElementAtOrDefault(2) != null) skillEffectName.ValueLv3 = skillEffectValues.ElementAt(2); if (skillEffectValues.ElementAtOrDefault(3) != null) skillEffectName.ValueLv4 = skillEffectValues. ElementAt(3); if (skillEffectValues.LastOrDefault() != null) skillEffectName.ValueScepter = skillEffectValues.Last(); using (Dota2Entities ctx = new Dota2Entities()) { try { skillEffectName = ctx.SkillEffectName.Add(skillEffectName); ctx.SaveChanges(); Console.WriteLine("Skill " + name + " Created"); } catch (Exception e) { throw e; } } } return skillEffectName; }
Skill insertSkill() { using (Dota2Entities ctx = new Dota2Entities()) { try { ctx.Skill.Add(this.skill); ctx.SaveChanges(); } catch (Exception e) { //TODO Adicionar ao log throw e; } } return this.skill; }