Esempio n. 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);
     }
 }
Esempio n. 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);
     }
 }
Esempio n. 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);
     }
 }
Esempio n. 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);
     }
 }
Esempio n. 5
0
 public ActeurRepository(MediaManagerContext context) : base(context)
 {
 }
Esempio n. 6
0
 public SaisonRepository(MediaManagerContext context) : base(context)
 {
 }
Esempio n. 7
0
 public SerieRepository(MediaManagerContext context) : base(context)
 {
 }
Esempio n. 8
0
 public FilmRepository(MediaManagerContext context) : base(context)
 {
 }
Esempio n. 9
0
 public EpisodeRepository(MediaManagerContext context) : base(context)
 {
 }