예제 #1
0
 public void AddUser(User user)
 {
     using (var db = new UsersAppContext())
     {
         db.Users.Add(user);
         db.SaveChanges();
     }
 }
예제 #2
0
 public void UpdateUserById(User user, int id)
 {
     using (var db = new UsersAppContext())
     {
         var foundUser = db.Users.FirstOrDefault(x => x.Id == id);
         foundUser = user;
         db.SaveChanges();
     }
 }
예제 #3
0
 public void RemoveUserById(int id)
 {
     using (var db = new UsersAppContext())
     {
         var user = db.Users.FirstOrDefault(x => x.Id == id);
         if (user != null)
         {
             db.Users.Remove(user);
             db.SaveChanges();
         }
     }
 }