//query function to check if workout exist in DB private static workout findWorkout(string workoutName) { social_workout_app_dbEntities db = new social_workout_app_dbEntities(); //get workout by workoutName workout _workout = db.workouts.Where(x => x.workoutName == workoutName).SingleOrDefault(); db.Dispose(); //check if workout exist if (_workout == null) { return(null); } return(_workout); }
//query function to check if task exist in DB private static task findTask(string taskName) { social_workout_app_dbEntities db = new social_workout_app_dbEntities(); //get task by taskName task _task = db.tasks.Where(x => x.taskName == taskName).SingleOrDefault(); db.Dispose(); //check if task exist if (_task == null) { return(null); } return(_task); }
//query function to check if user exist in DB private static user findUser(string userName) { social_workout_app_dbEntities db = new social_workout_app_dbEntities(); //get user by userName user user = db.users.Where(x => x.userName == userName).SingleOrDefault(); //check if user exist if (user == null) { return(null); } db.Dispose(); return(user); }
//query function to check if workout exist in DB private static workout findWorkoutByUsername(string _userName, string _workoutName) { social_workout_app_dbEntities db = new social_workout_app_dbEntities(); //get workout by workoutName //workout _workout = db.workouts.Where(x => x.userName == userName).Select(s => s.workoutName == workoutName).SingleOrDefault(); workout _workout = db.workouts.Where(x => x.workoutName == _workoutName && x.userName == _userName).SingleOrDefault(); db.Dispose(); //check if workout exist if (_workout == null) { return(null); } return(_workout); }
public static ItemTaskModel taskByNameResult(String _taskName) { //connect to db social_workout_app_dbEntities db = new social_workout_app_dbEntities(); task _task = db.tasks.Where(x => x.taskName == _taskName).SingleOrDefault(); db.Dispose(); ItemTaskModel taskModel = new ItemTaskModel { result = true, itemTask = _task }; return(taskModel); }
public static workoutModelList workoutsRessult(String _userName) { //connect to db social_workout_app_dbEntities db = new social_workout_app_dbEntities(); List <String> names = db.workouts.Where(s => s.userName == _userName).Select(s => s.workoutName).ToList(); db.Dispose(); workoutModelList workoutModel = new workoutModelList { result = true, workouts = names }; return(workoutModel); }
private static task checkTask(string taskName) { //connect to db social_workout_app_dbEntities db = new social_workout_app_dbEntities(); //get workout by workoutName task _task = db.tasks.Where(x => x.taskName == taskName).SingleOrDefault(); db.Dispose(); //check if workout exist and if workoutName is correct //if (_user == null || !Equals(user.password, CryptHelper.getHash(password))) if (_task == null || !workout.Equals(taskName, taskName)) { return(null); } return(_task); }
private static workout checkWorkout(string workoutName) { //connect to db social_workout_app_dbEntities db = new social_workout_app_dbEntities(); //get workout by workoutName workout _workout = db.workouts.Where(x => x.workoutName == workoutName).SingleOrDefault(); db.Dispose(); //check if workout exist and if workoutName is correct //if (_user == null || !Equals(user.password, CryptHelper.getHash(password))) if (_workout == null || !workout.Equals(workoutName, workoutName)) { return(null); } return(_workout); }
private static user checkLogin(string userName, string password) { //connect to db social_workout_app_dbEntities db = new social_workout_app_dbEntities(); //get user by userName user _user = db.users.Where(x => x.userName == userName).SingleOrDefault(); db.Dispose(); //check if user exist and if password is correct //if (_user == null || !Equals(user.password, CryptHelper.getHash(password))) if (_user == null || !user.Equals(password, password)) { return(null); } return(_user); }
public static taskModelList tasksRrssult(String _workoutName) { //connect to db social_workout_app_dbEntities db = new social_workout_app_dbEntities(); List <String> names = db.tasks.Where(s => s.workoutName == _workoutName).Select(s => s.taskName).ToList(); db.Dispose(); taskModelList taskModel = new taskModelList { result = true, tasksList = names }; return(taskModel); }
protected override void Dispose(bool disposing) { db.Dispose(); base.Dispose(disposing); }