public Trainer GetTrainerById(int TrainerID) { using (var context = new FitnessDBContext()) { return(context.Trainers.Where(t => t.TrainerID == TrainerID).FirstOrDefault()); } }
public Workout GetWorkoutById(int WorkoutID) { using (var context = new FitnessDBContext()) { return(context.Workouts.Where(w => w.WorkoutID == WorkoutID).FirstOrDefault()); } }
public void AddClient(Client client) { using (var db = new FitnessDBContext()) { db.Clients.Add(client); db.SaveChanges(); } }
public void AddTrainer(Trainer trainer) { using (var db = new FitnessDBContext()) { db.Trainers.Add(trainer); db.SaveChanges(); } }
public void AddWorkout(Workout workout) { using (var db = new FitnessDBContext()) { db.Workouts.Add(workout); db.SaveChanges(); } }
public IEnumerable <Client> GetAllClients() { using (var db = new FitnessDBContext()) { var clients = from c in db.Clients select c; return(clients.ToList()); } }
public IEnumerable <Trainer> GetAllTrainers() { using (var db = new FitnessDBContext()) { var trainers = from t in db.Trainers select t; return(trainers.ToList()); } }
public IEnumerable <Workout> GetAllWorkouts() { using (var db = new FitnessDBContext()) { var workouts = from w in db.Workouts select w; return(workouts.ToList()); } }
public IEnumerable <Client> GetClientsByTrainer(int TrainerID) { using (var db = new FitnessDBContext()) { var trainer = db.Trainers.Where(t => t.TrainerID == TrainerID).FirstOrDefault(); if (trainer != null) { return(trainer.Clientelle); } return(null); } }
public void DeleteClient(int ClientID) { using (var db = new FitnessDBContext()) { Client toRemove = db.Clients.SingleOrDefault(c => c.ClientID == ClientID); if (toRemove != null) { db.Clients.Remove(toRemove); } db.SaveChanges(); } }
public void DeleteTrainer(int TrainerID) { using (var db = new FitnessDBContext()) { var trainerToRemove = db.Trainers.SingleOrDefault(t => t.TrainerID == TrainerID); if (trainerToRemove != null) { db.Trainers.Remove(trainerToRemove); } db.SaveChanges(); } }
public void DeleteWorkout(int WorkoutID) { using (var db = new FitnessDBContext()) { var toRemove = db.Workouts.SingleOrDefault(w => w.WorkoutID == WorkoutID); if (toRemove != null) { db.Workouts.Remove(toRemove); } db.SaveChanges(); } }
public void EditWorkout(Workout workout) { using (var db = new FitnessDBContext()) { var toEdit = db.Workouts.SingleOrDefault(w => w.WorkoutID == workout.WorkoutID); if (toEdit != null) { toEdit.WorkoutName = workout.WorkoutName; toEdit.WorkoutDescription = workout.WorkoutDescription; toEdit.TrainerCreator = workout.TrainerCreator; toEdit.ClientsOnWorkout = workout.ClientsOnWorkout; } db.SaveChanges(); } }
public void EditTrainer(Trainer trainer) { using (var db = new FitnessDBContext()) { var toEdit = db.Trainers.SingleOrDefault(t => t.TrainerID == trainer.TrainerID); if (toEdit != null) { toEdit.TrainerName = trainer.TrainerName; toEdit.StartDate = trainer.StartDate; toEdit.HourlyRate = trainer.HourlyRate; toEdit.Clientelle = trainer.Clientelle; } db.SaveChanges(); } }
public void EditClient(Client client) { using (var db = new FitnessDBContext()) { var toEdit = db.Clients.SingleOrDefault(c => c.ClientID == client.ClientID); if (toEdit != null) { toEdit.ClientName = client.ClientName; toEdit.ClientJoinDate = client.ClientJoinDate; toEdit.CurrentWeight = client.CurrentWeight; toEdit.StartingWeight = client.StartingWeight; toEdit.FitnessGoals = client.FitnessGoals; toEdit.ClientTrainer = client.ClientTrainer; } db.SaveChanges(); } }