private static CharacterModel ToCharacterModel(CharacterProjection character) { return(new CharacterModel() { Id = character.Id, Name = character.Name, PlanetOfBirthId = character.PlanetOfBirthId, }); }
public async Task <CharacterProjection> InsertCharacterAsync(CharacterProjection projection) { using (var context = new SqlContext()) { var character = await context.Characters.AddAsync( new DbCharacter() { Name = projection.Name, PlanetOfBirthId = projection.PlanetOfBirthId, }); await context.SaveChangesAsync(); return(ToCharacterProjection(character.Entity)); } }