public DalFavorite GetFavorites(int id) { var result = new DalFavorite() { Target = id, Movies = context.Set<Favorites>().Where(x => x.UserId == id).Select(x => x.MovieId).ToArray() }; return result; }
public void Create(DalFavorite entity) { var favorite = new Favorites() { UserId = entity.UserId, MovieId = entity.MovieId }; context.Set<Favorites>().Add(favorite); context.SaveChanges(); }
public void Update(DalFavorite entity) { throw new NotImplementedException(); }
public void Delete(DalFavorite entity) { var result = context.Set<Favorites>().Where(x => x.UserId == entity.UserId && x.MovieId == entity.MovieId).Single(); context.Set<Favorites>().Remove(result); context.SaveChanges(); }