public ActionResult DeleteConfirmed(int id) { GPAState gPAState = db.GPAStates.Find(id); db.GPAStates.Remove(gPAState); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "GPAStateId,LowerLimit,UpperLimit,TuitionRateFactor")] GPAState gPAState) { if (ModelState.IsValid) { db.Entry(gPAState).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gPAState)); }
// GET api/GPAState/5 public GPAState GetGPAState(int id) { GPAState gpastate = db.GPAStates.Find(id); if (gpastate == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(gpastate); }
public ActionResult Create([Bind(Include = "GPAStateId,LowerLimit,UpperLimit,TuitionRateFactor")] GPAState gPAState) { if (ModelState.IsValid) { db.GPAStates.Add(gPAState); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gPAState)); }
public ActionResult DeleteConfirmed(int id) { GPAState gPAState = db.GPAStates.Find(id); if (gPAState.student != null) { gPAState.student.Clear(); } db.GPAStates.Remove(gPAState); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: GPAStates/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GPAState gPAState = db.GPAStates.Find(id); if (gPAState == null) { return(HttpNotFound()); } return(View(gPAState)); }
// POST api/GPAState public HttpResponseMessage PostGPAState(GPAState gpastate) { if (ModelState.IsValid) { db.GPAStates.Add(gpastate); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, gpastate); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = gpastate.GPAStateId })); return(response); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public MainPage() { state = new GPAState(); fileexists = state.load(filepath); course = state.getCourse(); InitializeComponent(); level4Group = new LevelGroup(Level.LEVEL_4, Tab4ModulePanel); level5Group = new LevelGroup(Level.LEVEL_5, Tab5ModulePanel); level6Group = new LevelGroup(Level.LEVEL_6, Tab6ModulePanel); level4SummaryGroups = new List<SummaryModuleGroup>(); level5SummaryGroups = new List<SummaryModuleGroup>(); level6SummaryGroups = new List<SummaryModuleGroup>(); tabControl1.Selected += new TabControlEventHandler(tabControl1_Selected); }
// DELETE api/GPAState/5 public HttpResponseMessage DeleteGPAState(int id) { GPAState gpastate = db.GPAStates.Find(id); if (gpastate == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } db.GPAStates.Remove(gpastate); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, gpastate)); }
// PUT api/GPAState/5 public HttpResponseMessage PutGPAState(int id, GPAState gpastate) { if (ModelState.IsValid && id == gpastate.GPAStateId) { db.Entry(gpastate).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
/// <summary> /// Registers a student for a given course. /// </summary> /// <param name="studentId"></param> /// <param name="courseId"></param> /// <param name="notes"></param> /// <returns></returns> public int registerCourse(int studentId, int courseId, string notes) { try { Registration incompleteCourseRecord = (from results in db.Registrations where results.StudentId == studentId where results.CourseId == courseId where results.Grade == null select results).SingleOrDefault(); if (incompleteCourseRecord != null) { //If the student has a pending registration, return -100 return(-100); } //Finding the amount of times the student has taken the course IQueryable <Registration> CourseAttempts = from results in db.Registrations where results.CourseId == courseId where results.StudentId == studentId select results; int studentAttempts = CourseAttempts.Count(); //If the course isn't a mastery course, maxAttempts returns null int?maxAttempts = (from results in db.MasteryCourses where results.CourseId == courseId select results.MaximumAttempts).SingleOrDefault(); if (maxAttempts != null) { if (studentAttempts >= maxAttempts && maxAttempts > 0) { //If the student has exceeded max attempts, return -200 return(-200); } } //If the conditions are satisfied, add the course BITCollege_TravisTaylor.Models.Registration newRegistration = new BITCollege_TravisTaylor.Models.Registration(); newRegistration.CourseId = courseId; newRegistration.StudentId = studentId; newRegistration.Notes = notes; newRegistration.RegistrationNumber = (long)StoredProcedures.nextNumber("NextRegistrationNumbers"); newRegistration.RegistrationDate = DateTime.Today; newRegistration.Grade = null; Course registeredCourse = (from results in db.Courses where results.CourseId == newRegistration.CourseId select results).SingleOrDefault(); Student student = (from results in db.Students where results.StudentId == studentId select results).SingleOrDefault(); GPAState state = (from results in db.GPAStates where results.GPAStateId == student.GPAStateId select results).SingleOrDefault(); double registrationTuition = registeredCourse.TuitionAmount; double adjustedTuitionRate = state.tuitionRateAdjustment(student); student.OutstandingFees += adjustedTuitionRate * registrationTuition; db.Registrations.Add(newRegistration); db.SaveChanges(); return(0); } catch (Exception exception) { //If any exceptions are thrown, return -300 return(-300); } }