public void AddUser(User user) { using (var db = new UsersAppContext()) { db.Users.Add(user); db.SaveChanges(); } }
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(); } }
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(); } } }