public ActionResult Create([Bind(Include = "ID,Completed,Note,AthleteID,WorkoutID")] Record record) { if (ModelState.IsValid) { db.Records.Add(record); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(record)); }
public ActionResult Create([Bind(Include = "WorkoutsId,WorkoutDate,TeamID")] Workout workout) { if (ModelState.IsValid) { db.Workouts.Add(workout); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TeamID = new SelectList(db.Teams, "TeamId", "TeamName", workout.TeamID); return(View(workout)); }
public ActionResult Create([Bind(Include = "ID,TeamName,CoachID")] Team team) { if (ModelState.IsValid) { db.Teams.Add(team); db.SaveChanges(); return(RedirectToAction("Index", "Home", new { area = "Coach" })); } ViewBag.CoachID = new SelectList(db.Coaches, "ID", "ID", team.CoachID); return(View(team)); }
public ActionResult Create([Bind(Include = "ExerciseRecordId,ComplexReps,ComplexSets,LiftWeight,RunSpeed,RunTime,RunDistance,ExerciseID,AthleteID")] ExerciseRecord exerciseRecord) { if (ModelState.IsValid) { db.ExerciseRecords.Add(exerciseRecord); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AthleteID = new SelectList(db.Athletes, "ID", "Sex", exerciseRecord.AthleteID); ViewBag.ExerciseID = new SelectList(db.Exercises, "ID", "Name", exerciseRecord.ExerciseID); return(View(exerciseRecord)); }
public ActionResult Create([Bind(Include = "ID,Sex,Gender,DOB,Height,Weight,TeamID")] Athlete athlete) { if (ModelState.IsValid) { db.Athletes.Add(athlete); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(db.Persons, "ID", "FirstName", athlete.ID); ViewBag.TeamID = new SelectList(db.Teams, "ID", "TeamName", athlete.TeamID); return(View(athlete)); }
public ActionResult UploadPhoto(HttpPostedFileBase postedFile) { byte[] bytes; using (BinaryReader br = new BinaryReader(postedFile.InputStream)) { bytes = br.ReadBytes(postedFile.ContentLength); } string ID = User.Identity.GetUserId(); Person person = db.Persons.Where(r => r.ASPNetIdentityID == ID).FirstOrDefault(); person.ProfilePic = bytes; db.SaveChanges(); return(RedirectToAction("Index")); }
public Peak_Performance.Models.Workout createWorkout() { try { Peak_Performance.Models.Workout workout = new Workout(); workout.Team = db.Teams.Find(this.team); workout.TeamID = db.Teams.Find(this.team).ID; workout.WorkoutDate = this.date; List <Complex> complexes = new List <Complex>(); foreach (ComplexViewModel comp in this.complexes) { Peak_Performance.Models.Complex complex = new Complex(); complex.Workout = workout; List <ComplexItem> complexItems = new List <ComplexItem>(); foreach (ExerciseViewModel ex in comp.complex) { if (db.Exercises.FirstOrDefault(e => e.Name == ex.name) != null) { Peak_Performance.Models.ComplexItem item = new ComplexItem(); item.Complex = complex; item.Exercis = db.Exercises.FirstOrDefault(e => e.Name == ex.name); item.ComplexReps = ex.reps; item.ComplexSets = ex.sets; item.LiftWeight = ex.weight; item.RunDistance = ex.distance; item.RunSpeed = ex.speed; item.RunTime = ex.time; complexItems.Add(item); db.ComplexItems.Add(item); } else { Peak_Performance.Models.ComplexItem item = new ComplexItem(); item.Complex = complex; item.ExerciseName = ex.name; item.ComplexReps = ex.reps; item.ComplexSets = ex.sets; item.LiftWeight = ex.weight; item.RunDistance = ex.distance; item.RunSpeed = ex.speed; item.RunTime = ex.time; complexItems.Add(item); db.ComplexItems.Add(item); } } complex.ComplexItems = complexItems; complexes.Add(complex); db.Complexes.Add(complex); } workout.Complexes = complexes; db.Workouts.Add(workout); db.SaveChanges(); return(workout); } catch (Exception ex) { throw ex; } }