Beispiel #1
0
 public static List <Film> GetAll()
 {
     try
     {
         List <Film> result;
         using (var context = new MediaManagerContext())
             using (var repository = new FilmRepository(context))
             {
                 result = repository.GetAll();
             }
         return(result);
     }
     catch (Exception ex)
     {
         throw new MediaManagerException($"Erreur : {ex.Message}", ExceptionReturnType.Error);
     }
 }
Beispiel #2
0
 public static void Delete(int id)
 {
     if (id <= 0)
     {
         throw new MediaManagerException($"Erreur : {nameof(id)} <= 0", ExceptionReturnType.Error);
     }
     try
     {
         using (var context = new MediaManagerContext())
             using (var repository = new FilmRepository(context))
             {
                 repository.Delete(id);
                 context.SaveChanges();
             }
     }
     catch (Exception ex)
     {
         throw new MediaManagerException($"Erreur : {ex.Message}", ExceptionReturnType.Error);
     }
 }
Beispiel #3
0
 public static void Save(Film element)
 {
     if (element == null)
     {
         throw new MediaManagerException($"Erreur : {nameof(element)} is null", ExceptionReturnType.Error);
     }
     try
     {
         using (var context = new MediaManagerContext())
             using (var repository = new FilmRepository(context))
             {
                 repository.Save(element);
                 context.SaveChanges();
             }
     }
     catch (Exception ex)
     {
         throw new MediaManagerException($"Erreur :{ex.Message}", ExceptionReturnType.Error);
     }
 }
Beispiel #4
0
 public static Film Get(int id)
 {
     if (id <= 0)
     {
         throw new MediaManagerException($"Erreur : {nameof(id)} <= 0", ExceptionReturnType.Error);
     }
     try
     {
         Film result;
         using (var context = new MediaManagerContext())
             using (var repository = new FilmRepository(context))
             {
                 result = repository.Get(id);
             }
         return(result);
     }
     catch (Exception ex)
     {
         throw new MediaManagerException($"Erreur : {ex.Message}", ExceptionReturnType.Error);
     }
 }
 public ActeurRepository(MediaManagerContext context) : base(context)
 {
 }
 public SaisonRepository(MediaManagerContext context) : base(context)
 {
 }
Beispiel #7
0
 public SerieRepository(MediaManagerContext context) : base(context)
 {
 }
Beispiel #8
0
 public FilmRepository(MediaManagerContext context) : base(context)
 {
 }
Beispiel #9
0
 public EpisodeRepository(MediaManagerContext context) : base(context)
 {
 }