public WorkoutService(IWorkoutRepo workoutRepo, IMapper mapper, IUserRepo userRepo, IUnitOfWork unitOfWork) { _workoutRepo = workoutRepo; _mapper = mapper; _userRepo = userRepo; _unitOfWork = unitOfWork; }
public ActionResult WorkoutList() { IWorkoutRepo repo = WorkoutRepoFactory.Create(); var model = repo.GetAllWorkouts(); return(View(model)); }
public ActionResult EditWorkout(WorkoutVM w) { IWorkoutRepo wrepo = WorkoutRepoFactory.Create(); IClientRepo repo = ClientRepoFactory.Create(); ITrainerRepo trepo = TrainerRepoFactory.Create(); if (ModelState.IsValid) { var workout = new Workout { WorkoutID = w.WorkoutID, WorkoutName = w.WorkoutName, WorkoutDescription = w.WorkoutDescription, }; foreach (var trainerID in w.SelectedTrainerID) { workout.TrainerCreator.Add(trepo.GetTrainerById(trainerID)); } foreach (var clientID in w.SelectedClientID) { workout.ClientsOnWorkout.Add(repo.GetClientById(clientID)); } wrepo.EditWorkout(workout); } return(RedirectToAction("WorkoutList")); }
public ActionResult DeleteWorkout(int WorkoutId) { IWorkoutRepo repo = WorkoutRepoFactory.Create(); repo.DeleteWorkout(WorkoutId); return(RedirectToAction("WorkoutList")); }
public WorkoutService(IWorkoutRepo workoutRepo, IMapper mapper, IUserRepo userRepo, IUnitOfWork unitOfWork, ILogger <WorkoutService> logger) { _workoutRepo = workoutRepo; _mapper = mapper; _userRepo = userRepo; _unitOfWork = unitOfWork; _logger = logger; }
public ExerciseService(IWorkoutRepo workoutRepo, IUnitOfWork unitOfWork, IMapper mapper, IExerciseRepo exerciseRepo, IShuffleService shuffleService) { _workoutRepo = workoutRepo; _unitOfWork = unitOfWork; _mapper = mapper; _exerciseRepo = exerciseRepo; _shuffleService = shuffleService; }
public ActionResult EditWorkout(int id) { IWorkoutRepo repo = WorkoutRepoFactory.Create(); var workout = repo.GetWorkoutById(id); var model = new WorkoutVM { WorkoutID = workout.WorkoutID, WorkoutName = workout.WorkoutName, WorkoutDescription = workout.WorkoutDescription, ClientsOnWorkout = workout.ClientsOnWorkout, TrainerCreator = workout.TrainerCreator }; return(View(model)); }
protected override void Seed(FitnessApp.UI.FitnessDBContext context) { //create repos and userMGr and roleMgr to use throughout seed data ITrainerRepo orgrepo = TrainerRepoFactory.Create(); IClientRepo herorepo = ClientRepoFactory.Create(); IWorkoutRepo locorepo = WorkoutRepoFactory.Create(); var userMgr = new UserManager <IdentityUser>(new UserStore <IdentityUser>(context)); var roleMgr = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context)); if (!roleMgr.RoleExists("User")) { var role = new IdentityRole(); role.Name = "User"; roleMgr.Create(role); } if (!userMgr.Users.Any(u => u.UserName == "user")) { var user = new IdentityUser() { UserName = "******" }; userMgr.Create(user, "testing"); } var findmanager = userMgr.FindByName("user"); // create the user with the manager class if (!userMgr.IsInRole(findmanager.Id, "user")) { userMgr.AddToRole(findmanager.Id, "user"); } if (!roleMgr.RoleExists("admin")) { roleMgr.Create(new IdentityRole() { Name = "admin" }); } if (!userMgr.Users.Any(u => u.UserName == "admin")) { var user = new IdentityUser() { UserName = "******" }; userMgr.Create(user, "testing"); } var finduser = userMgr.FindByName("admin"); // create the user with the manager class if (!userMgr.IsInRole(finduser.Id, "admin")) { userMgr.AddToRole(finduser.Id, "admin"); } if (!context.Trainers.Any(t => t.TrainerName == "Arnold")) { var firsttrainer = new Trainer { TrainerName = "Arnold", TrainerID = 1, HourlyRate = 25, StartDate = new DateTime(2017, 1, 18), }; context.Trainers.Add(firsttrainer); context.SaveChanges(); } var trainer = context.Trainers.First(t => t.TrainerName == "Arnold"); if (!context.Clients.Any(c => c.ClientName == "Jarid")) { var firstclient = new Client { ClientName = "Jarid", ClientID = 1, ClientJoinDate = new DateTime(2017, 3, 23), CurrentWeight = 158, StartingWeight = 133, FitnessGoals = "I gotta get jacked so girls will want this hot body", }; context.Clients.Add(firstclient); context.SaveChanges(); } var client = context.Clients.First(c => c.ClientName == "Jarid"); if (!context.Workouts.Any(w => w.WorkoutName == "5x5 StrongLifts")) { var firstworkout = new Workout { WorkoutID = 1, WorkoutName = "5x5 StrongLifts", WorkoutDescription = "5 sets of 5 reps. Squat, Bench, Deadlift, Overhead and Row. Add 5 pounds after each workout.", }; context.Workouts.Add(firstworkout); context.SaveChanges(); } var workout = context.Workouts.First(w => w.WorkoutName == "5x5 StrongLifts"); }
public WorkoutMgr() { repo = new WorkoutRepo(); }