/// <summary> /// Gets the user. /// </summary> /// <param name="email">The email.</param> /// <returns></returns> public static UserProfile GetUser(string email) { UserProfile profile = null; using (ExamSystemDataContext db = new ExamSystemDataContext()) { profile = (from p in db.UserProfiles where p.EmailAddress == email select p).FirstOrDefault(); } return profile; }
public static List<UserProfile> GetUsers(string searchString) { List<UserProfile> profiles = null; using (ExamSystemDataContext db = new ExamSystemDataContext()) { if (string.IsNullOrEmpty(searchString)) { profiles = (from p in db.UserProfiles select p).ToList(); } else { profiles = (from p in db.UserProfiles where SqlMethods.Like(p.EmailAddress, searchString) select p).ToList(); } } return profiles; }
public static UserProfile Save(UserProfile profile) { if (profile.UserId == 0) { //save the user. using (ExamSystemDataContext db = new ExamSystemDataContext()) { db.UserProfiles.InsertOnSubmit(profile); db.SubmitChanges(); } } else { //update user } return null; }