public int RatingAbove() { ctx = new MovieContext(); var count = ctx.Movies.Where(m => m.Type == 2).Where(m => (double)m.Rating >= 9.5).Count(); ctx.Dispose(); return(count); }
protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
public List <Movie> ReturnList(int type) { ctx = new MovieContext(); var list = ctx.Movies.Where(m => m.Type == type).ToList(); ctx.Dispose(); return(list); }
public int RatingBellow() { ctx = new MovieContext(); var count = ctx.Movies.Where(m => m.Type == 2).Where(m => (double)m.Rating <= 5.4).Count(); ctx.Dispose(); return(count); }
/// <summary> /// Очистка использованных объектов /// </summary> protected override void Dispose(bool disposing) { if (disposing) { _dbContext.Dispose(); } base.Dispose(disposing); }
public int RatingBetween(double min, double max) { ctx = new MovieContext(); var count = ctx.Movies.Where(m => m.Type == 2).Where(m => (double)m.Rating >= min && (double)m.Rating <= max).Count(); ctx.Dispose(); return(count); }
public List <Genre> AllGenres(int type) { ctx = new MovieContext(); var genres = ctx.Movies.Where(m => m.Type == type).SelectMany(g => g.Genres).Distinct().ToList(); ctx.Dispose(); return(genres); }
public int CountMoviesWatchlist() { ctx = new MovieContext(); var counter = ctx.Movies.Where(m => m.Type == 1).Count(); ctx.Dispose(); return(counter); }
public List <Movie> MoviesByGenre(string genre, int type) { ctx = new MovieContext(); var movies = ctx.Genres.Where(g => g.Name == genre).Select(m => m.Movies).SingleOrDefault().Where(t => t.Type == type).ToList(); ctx.Dispose(); return(movies); }
/// <summary> /// Disposes the repository /// </summary> public void Dispose() { if (_db != null) { _db.Dispose(); _db = null; } }
public void UpdateStatus(Movie movie, int?status) { ctx = new MovieContext(); var mov = ctx.Movies.Where(m => m.ImdbID == movie.ImdbID).FirstOrDefault(); mov.Type = status; ctx.SaveChanges(); ctx.Dispose(); }
protected override void Dispose(bool disposing) { // what happend when you click 'X' if (disposing) { db.Dispose(); } base.Dispose(disposing); }
protected virtual void Dispose(bool disposing) { if (disposing) { if (movieContext != null) { movieContext.Dispose(); } } }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _context.Dispose(); } } _disposed = true; }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { context.Dispose(); } } this.disposed = true; }
public double AverageRating() { ctx = new MovieContext(); var rating = ctx.Movies.Where(m => m.Type == 2).Select(m => (double?)m.Rating).Average(); ctx.Dispose(); if (rating == null) { return(0); } return((double)rating); }
public virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { } db.Dispose(); userManager.Dispose(); roleManager.Dispose(); clientManager.Dispose(); this.disposed = true; } }
private void CleanUp(bool disposing) { if (!disposed) { if (disposing) { //Освобождение управляемых ресурсов. dbContext.Dispose(); } else { //Очистка неуправляемых ресурсов. } disposed = true; } }
public string CountTimeSpent() { ctx = new MovieContext(); var time = ctx.Movies.Where(m => m.Type == 2).Select(m => m.Runtime).DefaultIfEmpty(0).Sum(); ctx.Dispose(); TimeSpan ts = TimeSpan.FromMinutes(time); int months; int days; int hours = ts.Hours; int minutes = ts.Minutes; if (ts.Days >= 30) { months = ts.Days / 30; days = ts.Days % 30; } else { days = ts.Days; months = 0; } if (months == 0 && days == 0 && hours == 0 && minutes == 0) { return(String.Format("You have not watched movies yet!")); } else if (months == 0 && days == 0 && hours == 0) { return(String.Format("{0} minutes", minutes)); } else if (months == 0 && days == 0) { return(String.Format("{0} hours, {1} minutes", hours, minutes)); } else if (months == 0) { return(String.Format("{0} days, {1} hours, {2} minutes", days, hours, minutes)); } else { return(String.Format("{0} months, {1} days, {2} hours, {3} minutes", months, days, hours, minutes)); } }
public string GenresByMovie(Movie movie) { ctx = new MovieContext(); var genres = ctx.Movies.Where(m => m.ImdbID == movie.ImdbID).Select(g => g.Genres).SingleOrDefault().ToList(); ctx.Dispose(); StringBuilder sb = new StringBuilder(); Genre last = genres.Last(); foreach (Genre g in genres) { if (g.Equals(last)) { sb.Append(g.Name); } else { sb.Append(g.Name + ", "); } } return(sb.ToString()); }
public void Dispose() { _movieContext.Dispose(); }
private void FormMain_FormClosed(object sender, FormClosedEventArgs e) { movieContext.Dispose(); listBoxMovies.Dispose(); }
public void Dispose() { _movieContext.Database.EnsureDeleted(); _movieContext.Dispose(); }
public void Dispose() { context.Dispose(); }