public void DeleteCharacterById(int id) { using (var context = new NewCharacterEntity()) { //Depending on foreign keys this may require reworking var query = context.Characters.SingleOrDefault(i => i.CharcterID == id); var bonds = query.Bonds.ToList(); bonds.ForEach(b => { query.Bonds.Remove(b); context.Bonds.Remove(b); }); var equipment = query.Equipments.ToList(); equipment.ForEach(e => { query.Equipments.Remove(e); context.Equipments.Remove(e); }); var features = query.Features_Traits.ToList(); features.ForEach(f => { query.Features_Traits.Remove(f); context.Features_Traits.Remove(f); }); var flaws = query.Flaws.ToList(); flaws.ForEach(f => { query.Flaws.Remove(f); context.Flaws.Remove(f); }); var ideals = query.Ideals.ToList(); ideals.ForEach(i => { query.Ideals.Remove(i); context.Ideals.Remove(i); }); var personality = query.PersonalityTraits.ToList(); personality.ForEach(p => { query.PersonalityTraits.Remove(p); context.PersonalityTraits.Remove(p); }); var lang = query.Prof_Lang.ToList(); lang.ForEach(l => { query.Prof_Lang.Remove(l); context.Prof_Lang.Remove(l); }); context.Characters.Remove(query); context.SaveChanges(); } }
public void AddNewCharacter(CharacterSheet model) { using (var context = new NewCharacterEntity()) { Character c = CharacterConverter(model); context.Characters.Add(c); // Create the Character context.SaveChanges(); } }
public CharacterSheet GetCharacterById(int id) { CharacterSheet result; using (var context = new NewCharacterEntity()) { var query = context.Characters.Single(i => i.CharcterID == id); result = CharacterSheetConverter(query); } return(result); }
public CharacterList GetAllCharacters() { CharacterList results = new CharacterList(); using (var context = new NewCharacterEntity()) { var query = context.Characters.Select(c => c); List <Character> list = new List <Character>(); list = query.ToList(); results.Characters = list; } return(results); }
public void AddIdealByCharacter(Character c, string ideal) { using (var context = new NewCharacterEntity()) { context.Characters.Attach(c); Ideal tempIdeal = new Ideal(); tempIdeal.CharacterID = c.CharcterID; tempIdeal.Character = c; tempIdeal.Ideals = ideal; context.Ideals.Add(tempIdeal); context.SaveChanges(); } }