Esempio n. 1
0
 public bool PutUser(user user)
 {
     try
     {
         if (ValidatorUser.IsUserExist(user, GetAllUser()) && ValidatorUser.IsValide(user))
         {
             db.Entry(user).State = EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
         else if (!ValidatorUser.IsUserExist(user, GetAllUser()))
         {
             throw new ItemNotExistException("user");
         }
         else
         {
             throw new InvalidItemException("user");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 2
0
 public bool PostUser(user user)
 {
     try
     {
         if (ValidatorUser.IsValide(user) && !ValidatorUser.IsUserExist(user, GetAllUser()))
         {
             db.users.Add(user);
             db.SaveChanges();
             return(true);
         }
         else if (ValidatorUser.IsUserExist(user, GetAllUser()))
         {
             throw new ExistingItemException("user");
         }
         else
         {
             throw new InvalidItemException("user");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }