/// <summary> /// Adds the specified character. /// There is no need to call Save() after this method. /// </summary> /// <param name="characterDTO">The character.</param> public void Add(CharacterDTO characterDTO) { var character = TemplateCharacter.Add(context, characterDTO); foreach (var baseStat in characterDTO.BaseStats) { TemplateCharacterBaseStat.Add(context, baseStat, character); } }
/// <summary> /// Adds the specified template characters to the given game. /// </summary> /// <param name="gameID">The game identifier.</param> /// <param name="characterIDsToAdd">The character ids to add.</param> public void Add(int gameID, List <int> characterIDsToAdd) { foreach (var id in characterIDsToAdd) { var templateCharacter = TemplateCharacter.Get(context, id); var gameCharacter = GameCharacter.Add(context, templateCharacter, gameID); foreach (var baseStat in templateCharacter.BaseStats) { GameCharacterBaseStat.Add(context, baseStat, gameCharacter); } } }
/// <summary> /// Generates the template character DTO from the character entity. /// </summary> /// <param name="character">The character.</param> /// <returns></returns> public static CharacterDTO GenerateDTOFromTemplateCharacter(TemplateCharacter character) { return(new CharacterDTO() { ID = character.ID, Name = character.Name, Description = character.Description, Level = character.Level, Race = character.Race != null?RaceDTO.CreateDTOFromRace(character.Race) : null, Class = character.Race != null?ClassDTO.CreateDTOFromClass(character.Class) : null, LastEdited = character.EditedDate ?? character.CreatedDate, BaseStats = character.BaseStats != null?character.BaseStats.Select(e => BaseStatDTO.GenerateDTOFromTemplateBaseStat(e)) : null }); }
/// <summary> /// Deletes the specified character. /// </summary> /// <param name="id"></param> public void Delete(int id) { TemplateCharacter.Delete(context, id); }
/// <summary> /// Updates the specified character. /// </summary> /// <param name="characterDTO">The character dto.</param> /// <exception cref="System.NotImplementedException"></exception> public void Update(CharacterDTO characterDTO) { TemplateCharacter.Update(context, characterDTO); }
/// <summary> /// Gets the specified template character. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public CharacterDTO GetDTO(int id) { return(TemplateCharacter.GetDTO(context, id)); }
/// <summary> /// Gets all template characters. /// </summary> /// <returns></returns> public IEnumerable <CharacterDTO> GetAll() { return(TemplateCharacter.GetAll(context)); }