public ActionResult Create(FormCollection collection) { Student.Models.Benchmark _Benchmark = new Student.Models.Benchmark(); try { // TODO: Add insert logic here using (TritonEntities EFDbContext = new TritonEntities()) { Student.Models.Benchmark _info = new Student.Models.Benchmark(); TryUpdateModel <Student.Models.Benchmark>(_info, collection); // Student _student = new Student(); _Benchmark.StudentID = _info.StudentID; _Benchmark.CourseID = _info.CourseID; _Benchmark.benchmarkRange = _info.benchmarkRange; EFDbContext.Benchmarks.Add(_Benchmark); EFDbContext.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Benchmark/Details/5 public ActionResult Details(int id) { Student.Models.Benchmark _Benchmark = new Student.Models.Benchmark(); using (TritonEntities EFDbContext = new TritonEntities()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var BenchmarkData = from BenchmarkTable in EFDbContext.Benchmarks where BenchmarkTable.BenchmarkID == id select BenchmarkTable; if (BenchmarkData.Any()) { _Benchmark.BenchmarkID = BenchmarkData.First().BenchmarkID; _Benchmark.CourseID = BenchmarkData.First().CourseID; _Benchmark.StudentID = BenchmarkData.First().StudentID; _Benchmark.benchmarkRange = BenchmarkData.First().benchmarkRange; } else { return(HttpNotFound()); } } return(View(_Benchmark)); }
// GET: Benchmark/Delete/5 public ActionResult Delete(int id) { Student.Models.Benchmark _Benchmark = new Student.Models.Benchmark(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (TritonEntities EFDbContext = new TritonEntities()) { var BenchmarkData = from BenchmarkTable in EFDbContext.Benchmarks where BenchmarkTable.BenchmarkID == id select BenchmarkTable; if (BenchmarkData.Any()) { //_student = studentData.First(); //EFDbContext.Students.Remove(_student); //EFDbContext.SaveChanges(); return(View(BenchmarkData)); } else { return(HttpNotFound()); } } return(View()); }
// GET: Benchmark/Edit/5 public ActionResult Edit(int id) { Student.Models.Benchmark _Benchmark = new Student.Models.Benchmark(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (TritonEntities EFDbContext = new TritonEntities()) { var BenchmarkData = from BenchmarkTable in EFDbContext.Benchmarks where BenchmarkTable.BenchmarkID == id select BenchmarkTable; if (BenchmarkData.Any()) { Dropdownlist _student = new Dropdownlist(); ViewBag.studentID = _student.DrowStudentID(); Dropdownlist _Course = new Dropdownlist(); ViewBag.CourseID = _Course.DrowCourseID(); _Benchmark.StudentID = BenchmarkData.First().StudentID; _Benchmark.BenchmarkID = BenchmarkData.First().BenchmarkID; _Benchmark.CourseID = BenchmarkData.First().CourseID; _Benchmark.benchmarkRange = BenchmarkData.First().benchmarkRange; //EFDbContext.SaveChanges(); return(View(_Benchmark)); } else { return(HttpNotFound()); } } return(View(_Benchmark)); }
public ActionResult Edit(int id, FormCollection collection) { Student.Models.Benchmark _Benchmark = new Student.Models.Benchmark(); try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (ModelState.IsValid) { using (TritonEntities EFDbContext = new TritonEntities()) { Student.Models.Benchmark _info = new Student.Models.Benchmark(); TryUpdateModel <Student.Models.Benchmark>(_info, collection); //var studentData = from studenTable in EFDbContext.Students // where studenTable.StudentID == id // select studenTable; //if (studentData.Any()) //{ _Benchmark.StudentID = _info.StudentID; _Benchmark.BenchmarkID = _info.BenchmarkID; _Benchmark.CourseID = _info.CourseID; _Benchmark.benchmarkRange = _info.benchmarkRange; EFDbContext.SaveChanges(); return(RedirectToAction("Index")); //} //else //{ // return HttpNotFound(); //} } } // TODO: Add update logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { Student.Models.Benchmark _Benchmark = new Student.Models.Benchmark(); try { // TODO: Add delete logic here if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (TritonEntities EFDbContext = new TritonEntities()) { Student.Models.Benchmark _info = new Student.Models.Benchmark(); TryUpdateModel <Student.Models.Benchmark>(_info, collection); //var studentData = from studenTable in EFDbContext.Students // where studenTable.StudentID == id // select studenTable; //if (studentData.Any()) //{ _Benchmark = _info; EFDbContext.Benchmarks.Remove(_Benchmark); EFDbContext.SaveChanges(); return(RedirectToAction("Index")); //} //else //{ // return HttpNotFound(); //} } } catch { return(View()); } }