Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
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);
     }
 }