Esempio n. 1
0
 public static User AddNewUser(User user)
 {
     try
     {
         using (CalendarEntities calendar = new CalendarEntities())
         {
             calendar.Users.Add(user);
             calendar.SaveChanges();
             return(user);
         }
     }
     catch
     {
         throw;
     }
 }
Esempio n. 2
0
 public static int DeleteUser(int id)
 {
     try
     {
         using (CalendarEntities calendar = new CalendarEntities())
         {
             var user = calendar.Users.FirstOrDefault(u => u.UserId == id);
             if (user != null)
             {
                 calendar.Users.Remove(user);
                 calendar.SaveChanges();
                 return(user.UserId);
             }
             return(-1);
         }
     }
     catch
     {
         throw;
     }
 }