public void Update(int id, ICharacterDatabase character) { if (id <= 0) { throw new ArgumentOutOfRangeException(nameof(id), "Id must be greater than zero"); } if (character == null) { throw new ArgumentNullException(nameof(character)); } ObjectValidator.ValidateFullObject(character); var existing = GetByName(character.Name); if (existing != null && existing.Id != id) { throw new InvalidOperationException("Movie must be unique"); } try { UpdateCore(id, character); } catch (Exception e) { throw new InvalidOperationException("Update Failed", e); }; }
public void Seed(ICharacterDatabase database) { var items = new[] { new Character() { Name = "Katarina", //Profession = "Rouge", //Race = "Human", Biography = "Greatest Assasin", Strength = 60, Intelligence = 60, Agility = 80, Constitution = 50, Charisma = 70, }, new Character() { Name = "Ganda", //Profession = "Elf", //Race = "Wizard", Biography = "White Wizard", Strength = 50, Intelligence = 85, Agility = 35, Constitution = 70, Charisma = 80, }, new Character() { Name = "Saurin", //Profession = "Elf", //Race = "Wizard", Biography = "Dark Lord", Strength = 70, Intelligence = 90, Agility = 20, Constitution = 20, Charisma = 50, } }; foreach (var item in items) { database.Add(item, out var error); } }
public ICharacterDatabase Add(ICharacterDatabase character) { if (character == null) { throw new ArgumentNullException(nameof(character)); } ObjectValidator.ValidateFullObject(character); var existing = GetByName(character.GetByName()); if (existing != null) { throw new InvalidOperationException("Movie must be unique"); } try { return(AddCore(character)); } catch (Exception e) { throw new InvalidOperationException("Add Failed", e); }; }
public static void Seed(this ICharacterDatabase source) { source.Add(new Character() { Name = "Ant", Profession = "Fighter", Race = "Dwarf", Strength = 69, Intelligence = 46, Agility = 78, Constitution = 32, Charisma = 20, }); source.Add(new Character() { Name = "Hawk", Profession = "Hunter", Race = "Half Elf", Strength = 67, Intelligence = 42, Agility = 77, Constitution = 30, Charisma = 25, }); source.Add(new Character() { Name = "Intel", Profession = "Priest", Race = "Half Elf", Strength = 65, Intelligence = 95, Agility = 74, Constitution = 60, Charisma = 30, }); source.Add(new Character() { Name = "Hero", Profession = "Fighter", Race = "Human", Strength = 62, Intelligence = 49, Agility = 72, Constitution = 34, Charisma = 36, }); source.Add(new Character() { Name = "Olimar", Profession = "Fighter", Race = "Human", Strength = 99, Intelligence = 99, Agility = 99, Constitution = 99, Charisma = 99, }); }
internal static void ValidateFullObject(ICharacterDatabase character) { throw new NotImplementedException(); }
protected abstract ICharacterDatabase UpdateCore(int id, ICharacterDatabase character);
protected abstract ICharacterDatabase AddCore(ICharacterDatabase character);