Ejemplo n.º 1
0
 public bool PutGenre(genre genre)
 {
     try
     {
         if (ValidatorGenre.IsGenreExist(genre, GetAllGenre()) && ValidatorGenre.IsValide(genre))
         {
             db.Entry(genre).State = EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
         else if (!ValidatorGenre.IsGenreExist(genre, GetAllGenre()))
         {
             throw new ItemNotExistException("genre");
         }
         else
         {
             throw new InvalidItemException("genre");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 2
0
 public bool PostGenre(genre genre)
 {
     try
     {
         if (ValidatorGenre.IsValide(genre) && !ValidatorGenre.IsGenreExist(genre, GetAllGenre()))
         {
             db.genres.Add(genre);
             db.SaveChanges();
             return(true);
         }
         else if (ValidatorGenre.IsGenreExist(genre, GetAllGenre()))
         {
             throw new ExistingItemException("genre");
         }
         else
         {
             throw new InvalidItemException("genre");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }