Exemple #1
0
 public int AddOrUpdate(UniUser user)
 {
     try
     {
         using (UniUserDbContext db = new UniUserDbContext(ConnectionString))
         {
             db.UniUsers.AddOrUpdate(user);
             db.SaveChanges();
             return user.UserId;
         }
     }
     catch (Exception e)
     {
         if (user == null)
         {
             throw new Exception("Error Adding Updating User: User null", e);
         }
         throw new Exception(
             "Error Adding/Updating User: {Id:" + user.UserId + " Email:" + user.EmailAddress + "}", e);
     }
 }
Exemple #2
0
 public bool Remove(UniUser user)
 {
     try
     {
         using (UniUserDbContext db = new UniUserDbContext(ConnectionString))
         {
             db.UniUsers.Attach(user);
             db.UniUsers.Remove(user);
             db.SaveChanges();
             return true;
         }
     }
     catch (Exception e)
     {
         if (user == null)
         {
             throw new Exception("Error Removing User: User null", e);
         }
         throw new Exception("Error Removing User: {Id:" + user.UserId + " Email:" + user.EmailAddress + "}", e);
     }
 }