示例#1
0
        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);
 }
示例#3
0
        public List <Movie> ReturnList(int type)
        {
            ctx = new MovieContext();
            var list = ctx.Movies.Where(m => m.Type == type).ToList();

            ctx.Dispose();
            return(list);
        }
示例#4
0
        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);
        }
示例#5
0
 /// <summary>
 /// Очистка использованных объектов
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _dbContext.Dispose();
     }
     base.Dispose(disposing);
 }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        public int CountMoviesWatchlist()
        {
            ctx = new MovieContext();
            var counter = ctx.Movies.Where(m => m.Type == 1).Count();

            ctx.Dispose();
            return(counter);
        }
示例#9
0
        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);
        }
示例#10
0
 /// <summary>
 /// Disposes the repository
 /// </summary>
 public void Dispose()
 {
     if (_db != null)
     {
         _db.Dispose();
         _db = null;
     }
 }
示例#11
0
        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();
         }
     }
 }
示例#14
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _context.Dispose();
         }
     }
     _disposed = true;
 }
示例#15
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             context.Dispose();
         }
     }
     this.disposed = true;
 }
示例#16
0
        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);
        }
示例#17
0
 public virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
         }
         db.Dispose();
         userManager.Dispose();
         roleManager.Dispose();
         clientManager.Dispose();
         this.disposed = true;
     }
 }
示例#18
0
        private void CleanUp(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    //Освобождение управляемых ресурсов.
                    dbContext.Dispose();
                }
                else
                {
                    //Очистка неуправляемых ресурсов.
                }

                disposed = true;
            }
        }
示例#19
0
        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));
            }
        }
示例#20
0
        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());
        }
示例#21
0
 public void Dispose()
 {
     _movieContext.Dispose();
 }
示例#22
0
 private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
 {
     movieContext.Dispose();
     listBoxMovies.Dispose();
 }
示例#23
0
 public void Dispose()
 {
     _movieContext.Database.EnsureDeleted();
     _movieContext.Dispose();
 }
示例#24
0
 public void Dispose()
 {
     context.Dispose();
 }