public User GetUser(int id) { using (var videoStore = new VideoStoreContext()) { return(videoStore.Users.Find(id)); } }
public IEnumerable <User> GetUsers() { using (var videoStore = new VideoStoreContext()) { return(videoStore.Users.ToList()); } }
public IEnumerable <Movie> GetMovies() { using (var videoStore = new VideoStoreContext()) { return(videoStore.Movies.ToList()); } }
public Movie GetMovie(int id) { using (var videoStore = new VideoStoreContext()) { return(videoStore.Movies.Find(id)); } }
public void DeleteRental(Rental rental) { using (var videoStore = new VideoStoreContext()) { DeleteRental(videoStore, rental); videoStore.SaveChanges(); } }
public IEnumerable <RentedMovie> GetRentedMoviesByMovie(int movieId) { using (var videoStore = new VideoStoreContext()) { return(videoStore.RentedMovies .Where(r => r.MovieId == movieId) .ToList()); } }
public IEnumerable <Rental> GetRentals() { using (var videoStore = new VideoStoreContext()) { return(videoStore.Rentals .Include(r => r.Movie) .Include(r => r.User) .ToList()); } }
public void DeleteRentals(IEnumerable <Rental> rentals) { using (var videoStore = new VideoStoreContext()) { foreach (var item in rentals) { DeleteRental(videoStore, item); } videoStore.SaveChanges(); } }
public Rental GetRental(int id) { using (var videoStore = new VideoStoreContext()) { var rental = videoStore.Rentals .Where(r => r.Id == id) .Include(r => r.Movie) .Include(r => r.User) .FirstOrDefault(); return(rental); } }
private void DeleteRental(VideoStoreContext videoStore, Rental rental) { ++rental.Movie.NumOfCopies; videoStore.Movies.Attach(rental.Movie); videoStore.Entry(rental.Movie).Property(m => m.NumOfCopies).IsModified = true; rental.User = null; rental.Movie = null; videoStore.Rentals.Attach(rental); videoStore.Rentals.Remove(rental); }
public CartController(UserManager <ApplicationUser> userManager) { cartServiceUri = new Uri(FabricRuntime.GetActivationContext() .ApplicationName + "/StatefulCart"); purchaseServiceApiUri = new Uri(FabricRuntime.GetActivationContext() .ApplicationName + "/TestWebApi"); _db = new VideoStoreContext(); _userManager = userManager; fabricClient = new FabricClient(); commFactory = new HttpCommunicationClientFactory( new ServicePartitionResolver(() => fabricClient)); }
private void AddRental(VideoStoreContext videoStore, Rental rental) { var rentedMovie = new RentedMovie { MovieId = rental.MovieId, UserId = rental.UserId, }; --rental.Movie.NumOfCopies; videoStore.Movies.Attach(rental.Movie); videoStore.Entry(rental.Movie).Property(m => m.NumOfCopies).IsModified = true; rental.Movie = null; rental.User = null; videoStore.Rentals.Add(rental); videoStore.RentedMovies.Add(rentedMovie); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, VideoStoreContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } context.Database.Migrate(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public CosmosDbFrameworkIntegrationTests(CosmosFixture cosmosFixture) { _videoStoreContext = cosmosFixture.VideoStoreContext; }
public HomeController() { _db = new VideoStoreContext(); }
public void Dispose() { VideoStoreContext = null; }
public MoviesController(VideoStoreContext context) { db = context; }
public CustomerService() { _db = new VideoStoreContext(); }