Ejemplo n.º 1
0
        public void Count_WhereSpecification()
        {
            var films = new Films(ProviderName);
            var total = films.Count(where : "WHERE rental_duration=@0", args: 5);

            Assert.AreEqual(191, total);
        }
Ejemplo n.º 2
0
        public void Count_NoSpecification()
        {
            var films = new Films(ProviderName);
            var total = films.Count();

            Assert.AreEqual(1000, total);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Retourne les "nombreTop" films ayant la meilleure note
 /// </summary>
 /// <param name="nombreTop">Le nombre de films a retourner</param>
 /// <returns>La collection de films</returns>
 public IEnumerable <Film> recupereTopFilms(int nombreTop)
 {
     if (nombreTop > Films.Count())
     {
         nombreTop = Films.Count();
     }
     return(Films.OrderByDescending(f => f.Note).Take(nombreTop));
 }
Ejemplo n.º 4
0
 public int FilmsUsingGenre(int genreId)
 {
     try
     {
         var genre = Genres.Single(g => g.Id.Equals(genreId));
         var count = Films.Count(f => f.Genres.Contains(genre));
         return(count);
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 5
0
        public Task <bool> SaveChangesAsync()
        {
            return(Task.Run(() =>
            {
                if (FilmsToAdd.Count() <= 0 && ActorsToAdd.Count() <= 0 &&
                    DirectorsToAdd.Count() <= 0 && FilmsToDelete.Count() <= 0 &&
                    ActorsToDelete.Count() <= 0 && DirectorsToDelete.Count() <= 0)
                {
                    return false;
                }

                foreach (var film in FilmsToAdd)
                {
                    film.Id = Films.Count() + 1;
                    Films.Add(film);
                }
                foreach (var actor in ActorsToAdd)
                {
                    actor.Id = Actors.Count() + 1;
                    Actors.Add(actor);
                }
                foreach (var director in DirectorsToAdd)
                {
                    director.Id = Directors.Count() + 1;
                    Directors.Add(director);
                }

                foreach (var film in FilmsToDelete)
                {
                    var filmInList = Films.Where(f => f.Id == film.Id).FirstOrDefault();
                    Films.Remove(filmInList);
                }
                foreach (var actor in ActorsToDelete)
                {
                    var actorInList = Actors.Where(f => f.Id == actor.Id).FirstOrDefault();
                    Actors.Remove(actorInList);
                }
                foreach (var director in DirectorsToDelete)
                {
                    var directorInList = Directors.Where(f => f.Id == director.Id).FirstOrDefault();
                    Directors.Remove(directorInList);
                }

                Initialize();
                return true;
            }));
        }
 public int PageCount()
 {
     return(Convert.ToInt32(Math.Ceiling(Films.Count() / (double)FilmPerPage)));
 }