//get user public User getUser(string username) { var user = new User(); using (var db = new HealthModelsDataContext()) { var query = db.Users.SingleOrDefault(targetUser => targetUser.userName.Equals(username)); user = query; } return user; }
//create user public void createUser(string firstName, string lastName, string username, string password, string role) { using (var db = new HealthModelsDataContext()) { var user = new User(); user.firstName = firstName; user.lastName = lastName; user.userName = username; user.password = password; user.role = role; db.Users.InsertOnSubmit(user); db.SubmitChanges(); } }
//update user public void updateUser(string firstName, string lastName, string username, string password, string role) { var user = new User(); using (var db = new HealthModelsDataContext()) { user = db.Users.SingleOrDefault(targetUser => targetUser.userName.Equals(username)); if(user!=null) { user.firstName = firstName; user.lastName = lastName; user.password = password; user.role = role; db.SubmitChanges(); } } }
partial void DeleteUser(User instance);
partial void UpdateUser(User instance);
partial void InsertUser(User instance);