public async Task <IActionResult> Edit(int id, [Bind("ExerciseId,ExerciseName,CategoryId")] Exercis exercis) { if (id != exercis.ExerciseId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(exercis); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ExercisExists(exercis.ExerciseId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryId", exercis.CategoryId); return(View(exercis)); }
public IHttpActionResult PutExercis(int id, Exercis exercis) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != exercis.Id) { return(BadRequest()); } db.Entry(exercis).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ExercisExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { Exercis exercis = db.Exercises.Find(id); db.Exercises.Remove(exercis); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Name,HowTo,Equipment,ResourceVideo,ResourcePhoto,ResourceText")] Exercis exercis) { if (ModelState.IsValid) { db.Entry(exercis).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(exercis)); }
public ActionResult Edit([Bind(Include = "Id,Name,Description")] Exercis exercis) { if (ModelState.IsValid) { db.Entry(exercis).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(exercis)); }
public IHttpActionResult GetExercis(int id) { Exercis exercis = db.Exercises.Find(id); if (exercis == null) { return(NotFound()); } return(Ok(exercis)); }
public ActionResult Edit([Bind(Include = "ExID,ExName,ExDesc,ExPic1,ExVid,RXID,DurID")] Exercis exercis) { if (ModelState.IsValid) { db.Entry(exercis).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RXID = new SelectList(db.Rx2, "RXID", "RxName", exercis.RXID); return(View(exercis)); }
public ActionResult Edit([Bind(Include = "Id,Name,Description,NumReps,RestTime,Weight,Workout_Id")] Exercis exercis) { if (ModelState.IsValid) { db.Entry(exercis).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Workout_Id = new SelectList(db.Workouts, "Id", "Name", exercis.Workout_Id); return(View(exercis)); }
public ActionResult Create([Bind(Include = "Id,Name,Description")] Exercis exercis) { if (ModelState.IsValid) { db.Exercises.Add(exercis); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(exercis)); }
public ActionResult Create([Bind(Include = "ID,Name,HowTo,Equipment,ResourceVideo,ResourcePhoto,ResourceText")] Exercis exercis) { if (ModelState.IsValid) { db.Exercises.Add(exercis); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(exercis)); }
public IHttpActionResult PostExercis(Exercis exercis) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Exercises.Add(exercis); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = exercis.Id }, exercis)); }
public ActionResult Create([Bind(Include = "ExID,ExName,ExDesc,ExPic1,ExVid,RxID,DurID")] Exercis exercis) { if (ModelState.IsValid) { db.Exercises.Add(exercis); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RxID = new SelectList(db.RXes, "RxID", "RxName", exercis.RxID); return(View(exercis)); }
public async Task <IActionResult> Create([Bind("ExerciseId,ExerciseName,CategoryId")] Exercis exercis) { if (ModelState.IsValid) { _context.Add(exercis); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryId", exercis.CategoryId); return(View(exercis)); }
public IHttpActionResult DeleteExercis(int id) { Exercis exercis = db.Exercises.Find(id); if (exercis == null) { return(NotFound()); } db.Exercises.Remove(exercis); db.SaveChanges(); return(Ok(exercis)); }
// GET: Exercis/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Exercis exercis = db.Exercises.Find(id); if (exercis == null) { return(HttpNotFound()); } return(View(exercis)); }
// GET: Exercis/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Exercis exercis = db.Exercises.Find(id); if (exercis == null) { return(HttpNotFound()); } ViewBag.Workout_Id = new SelectList(db.Workouts, "Id", "Name", exercis.Workout_Id); return(View(exercis)); }
// GET: Exercis/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Exercis exercis = db.Exercises.Find(id); if (exercis == null) { return(HttpNotFound()); } ViewBag.RXID = new SelectList(db.Rx2, "RXID", "RxName", exercis.RXID); return(View(exercis)); }
public ActionResult Edit(ExerciseViewModel exerciseVM) { Exercis exercise = new Exercis(); exercise = db.Exercises.SingleOrDefault(x => x.Id == exerciseVM.Exercise.Id); exercise.Question = exerciseVM.Exercise.Question; exercise.Hint = exerciseVM.Exercise.Hint; exercise.CorrectAnswer = exerciseVM.Exercise.CorrectAnswer; exercise.Answer1 = exerciseVM.Exercise.Answer1; exercise.Answer2 = exerciseVM.Exercise.Answer2; exercise.Answer3 = exerciseVM.Exercise.Answer3; exercise.Answer4 = exerciseVM.Exercise.Answer4; if (ModelState.IsValid) { db.Entry(exercise).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Show", "Example", new { exampleID = exerciseVM.Exercise.ExampleID })); }
public ActionResult StoreStudentRecord(ExampleViewModel exampleVM) { bool checkExist = false; int userID = (int)Session["userID"]; int exerciseID = exampleVM.StudentRecord.ExerciseID; Exercis currentExercise = db.Exercises.SingleOrDefault(x => x.Id == exerciseID); string submittedAnswer = exampleVM.StudentRecord.TempAnswer; string correctAnswer = ""; if (currentExercise.CorrectAnswer == "Answer1") { correctAnswer = currentExercise.Answer1; } else if (currentExercise.CorrectAnswer == "Answer2") { correctAnswer = currentExercise.Answer2; } else if (currentExercise.CorrectAnswer == "Answer3") { correctAnswer = currentExercise.Answer3; } else if (currentExercise.CorrectAnswer == "Answer4") { correctAnswer = currentExercise.Answer4; } checkExist = db.StudentRecords.Any(x => x.UserID == userID && x.ExerciseID == exerciseID); StudentRecord existingStudentRecord = db.StudentRecords.SingleOrDefault(x => x.UserID == userID && x.ExerciseID == exerciseID); if (checkExist && existingStudentRecord.CorrectAttempt == null) { //if student record exist update the record. if (existingStudentRecord.Attempt2 == null) { existingStudentRecord.Attempt2 = submittedAnswer; if (submittedAnswer == correctAnswer) { existingStudentRecord.CorrectAttempt = "Attempt2"; } } else if (existingStudentRecord.Attempt3 == null) { existingStudentRecord.Attempt3 = submittedAnswer; if (submittedAnswer == correctAnswer) { existingStudentRecord.CorrectAttempt = "Attempt3"; } } else { existingStudentRecord.Attempt4 = submittedAnswer; if (submittedAnswer == correctAnswer) { existingStudentRecord.CorrectAttempt = "Attempt4"; } } existingStudentRecord.Date = DateTime.Now; if (ModelState.IsValid) { db.Entry(existingStudentRecord).State = EntityState.Modified; db.SaveChanges(); } } else if (!checkExist) { //if student record not exist then create a new student record StudentRecord newStudentRecord = new StudentRecord(); newStudentRecord.UserID = userID; newStudentRecord.ExerciseID = exerciseID; newStudentRecord.Attempt1 = submittedAnswer; if (submittedAnswer == correctAnswer) { newStudentRecord.CorrectAttempt = "Attempt1"; } newStudentRecord.Date = DateTime.Now; db.StudentRecords.Add(newStudentRecord); db.SaveChanges(); } //send feedback string feedbackMessage; if (submittedAnswer == correctAnswer) { feedbackMessage = "Well done! Correct Answer."; } else { feedbackMessage = "Wrong Answer!"; } return(RedirectToAction("Show", "Example", new { exampleID = currentExercise.ExampleID, feedback = feedbackMessage })); }