Exemplo n.º 1
0
        public void EnrollBodybuilderInWorkot(int workoutId, Bodybulder bodybuilder)
        {
            Workout wantedWorkout = this.Context.Workouts.Find(workoutId);

            bodybuilder.Workouts.Add(wantedWorkout);
            this.Context.SaveChanges();
        }
Exemplo n.º 2
0
        public Bodybulder GetCurrentBodybuilder(string userName)
        {
            var        user        = this.Context.Users.FirstOrDefault(applicationUser => applicationUser.UserName == userName);
            Bodybulder bodybuilder = this.Context.Bodybulders.FirstOrDefault(builder => builder.User.Id == user.Id);

            return(bodybuilder);
        }
Exemplo n.º 3
0
        public ActionResult Enroll(int workoutId)
        {
            string     userName    = User.Identity.Name;
            Bodybulder bodybuilder = this.service.GetCurrentBodybuilder(userName);

            this.service.EnrollBodybuilderInWorkot(workoutId, bodybuilder);
            return(RedirectToAction("Profile"));
        }
Exemplo n.º 4
0
        public void CreateBodybouilder(ApplicationUser user)
        {
            Bodybulder      bodybulder  = new Bodybulder();
            ApplicationUser currentUser = this.Context.Users.Find(user.Id);

            bodybulder.User = currentUser;
            this.Context.Bodybulders.Add(bodybulder);
            this.Context.SaveChanges();
        }
Exemplo n.º 5
0
        public ProfileVm GetProfileVm(string userName)
        {
            ApplicationUser currentUser = this.Context.Users.FirstOrDefault(
                user => user.UserName == userName);
            ProfileVm  vm = Mapper.Map <ApplicationUser, ProfileVm>(currentUser);
            Bodybulder currentBodybuilder =
                this.Context.Bodybulders.FirstOrDefault(bodybuilder => bodybuilder.User.Id == currentUser.Id);

            vm.EnrolledWorkouts = Mapper.Map <IEnumerable <Workout>, IEnumerable <UserWorkoutVm> >(currentBodybuilder.Workouts);
            return(vm);
        }