public async Task <ActorDetailedDTO> CreateAsync(ActorCreateUpdateDTO actor) { var entity = new Actor { Name = actor.Name }; _context.Actors.Add(entity); await _context.SaveChangesAsync(); return(await FindAsync(entity.Id)); }
public async Task <CharacterDTO> CreateAsync(CharacterCreateUpdateDTO character) { var entity = new Character { ActorId = character.ActorId, Name = character.Name, Species = character.Species, Planet = character.Planet, }; _context.Characters.Add(entity); await _context.SaveChangesAsync(); return(await FindAsync(entity.Id)); }
public async Task <EpisodeDetailedDTO> CreateAsync(EpisodeCreateUpdateDTO episode) { var entity = new Episode { Title = episode.Title, FirstAired = episode.FirstAired, EpisodeCharacters = episode.CharacterIds.Select(c => new EpisodeCharacter { CharacterId = c }).ToList() }; _context.Episodes.Add(entity); await _context.SaveChangesAsync(); return(await FindAsync(entity.Id)); }
public async Task <int> CreateAsync(CharacterCreateDTO character) { var entity = new Character { ActorId = character.ActorId, Name = character.Name, Species = character.Species, Planet = character.Planet, Image = character.Image }; _context.Characters.Add(entity); await _context.SaveChangesAsync(); return(entity.Id); }
public async Task <bool> DeleteAsync(int characterId) { var character = await _context.Characters.FindAsync(characterId); if (character == null) { return(false); } _context.Characters.Remove(character); await _context.SaveChangesAsync(); return(true); }