public ActionResult Create([Bind(Include = "GroupId,GroupName")] MuscleGroup muscleGroup)
        {
            if (ModelState.IsValid)
            {
                db.MuscleGroups.Add(muscleGroup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(muscleGroup));
        }
Exemple #2
0
      public ActionResult Create([Bind(Include = "UserId,Email,UserRoleID")] Account account)
      {
          if (ModelState.IsValid)
          {
              db.Accounts.Add(account);
              db.SaveChanges();
              return(RedirectToAction("Index"));
          }

          return(View(account));
      }
Exemple #3
0
        public ActionResult Create([Bind(Include = "ExerciseId,ExerciseName,ExerciseDescription,GroupId")] Exercise exercise)
        {
            if (ModelState.IsValid)
            {
                db.Exercises.Add(exercise);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GroupId = new SelectList(db.MuscleGroups, "GroupId", "GroupName", exercise.GroupId);
            return(View(exercise));
        }
Exemple #4
0
        public ActionResult Create([Bind(Include = "WorkoutId,WorkoutName,UserName")] Workout workout)
        {
            if (ModelState.IsValid)
            {
                db.Workouts.Add(workout);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserName = new SelectList(db.Accounts, "UserName", "Email", workout.UserId);
            return(View(workout));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "CommentId,UserId,WorkoutId,CommentDateTime,TextBody")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                db.Comments.Add(comment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId    = new SelectList(db.Accounts, "UserId", "Email", comment.UserId);
            ViewBag.WorkoutId = new SelectList(db.Workouts, "WorkoutId", "WorkoutName", comment.WorkoutId);
            return(View(comment));
        }
        public ActionResult Create([Bind(Include = "StepId,WorkoutId,ExerciseId,WorkoutOrder,RepsNumber,SetsNumber")] WorkoutStep workoutStep)
        {
            if (ModelState.IsValid)
            {
                db.WorkoutSteps.Add(workoutStep);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ExerciseId = new SelectList(db.Exercises, "ExerciseId", "ExerciseName", workoutStep.ExerciseId);
            ViewBag.WorkoutId  = new SelectList(db.Workouts, "WorkoutId", "WorkoutName", workoutStep.WorkoutId);
            return(View(workoutStep));
        }
Exemple #7
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    string role;
                    if (model.IsTrainer)
                    {
                        role = "Trainer";
                    }
                    else
                    {
                        role = "User";
                    }
                    UserManager.AddToRole(user.Id, role);

                    var account = new Account
                    {
                        UserRole = role, Email = model.Email, UserId = user.Id
                    };
                    using (var db = new FlexGainsEntities())
                    {
                        db.Accounts.Add(account);
                        db.SaveChanges();
                    }
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }