public bool CreateMovie(MovieCreate model) { var entity = new Movie() { Title = model.Title }; using (var ctx = new ClassesDbContext()) { ctx.Movies.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateCharacterMovie(CharacterMovieCreate model) { var entity = new CharacterMovie() { CharacterId = model.CharacterId, MovieId = model.MovieId }; using (var ctx = new ClassesDbContext()) { ctx.CharacterMovies.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateCharacter(CharacterCreate model) { var entity = new Character() { RealName = model.RealName, AlterEgo = model.AlterEgo }; using (var ctx = new ClassesDbContext()) { ctx.Characters.Add(entity); return(ctx.SaveChanges() == 1); } }
public CharacterDetail GetCharacterById(int id) { using (var ctx = new ClassesDbContext()) { var entity = ctx .Characters .Single(e => e.Id == id); return (new CharacterDetail { RealName = entity.RealName, AlterEgo = entity.AlterEgo, Movies = GetMovieStrings(id) }); } }
public List <CharacterMovieListItem> GetCharacterMovieMovieIds(int actorId) { //List<CharacterMovie> characterMovies = new List<CharacterMovie>(); using (var ctx = new ClassesDbContext()) { var query = ctx .CharacterMovies .Where(e => e.CharacterId == actorId) .Select( e => new CharacterMovieListItem { MovieId = e.MovieId, CharacterId = e.CharacterId } ); return(query.ToList()); } }
public IEnumerable <MovieListItem> GetMovies(int actorId) { //return list of movies where the actordId matches the movieIds in charactermovie that are tied to that actorId List <CharacterMovieListItem> characterMovies = GetCharacterMovieMovieIds(actorId); List <int> movieIds = GetMovieIdsFromList(characterMovies); using (var ctx = new ClassesDbContext()) { var query = ctx .Movies .Where(e => movieIds.Contains(e.Id)) .Select( e => new MovieListItem { Title = e.Title } ); return(query.ToArray()); } }