public ActionResult DeleteConfirmed(int id)
        {
            enrollment enrollment = db.enrollments.Find(id);

            db.enrollments.Remove(enrollment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult CreateEnrollment(enrollment e)
 {
     e.id     = new EnrollmentService().getMaxID() + 1;
     e.userID = int.Parse(Session["loggedUser"].ToString());
     e.grade  = 0;
     new EnrollmentService().addEnrollment(e);
     return(RedirectToAction("ViewEnrollments"));
 }
 public ActionResult Edit([Bind(Include = "EnrollmentID,CourseID,TraineeID")] enrollment enrollment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(enrollment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CourseID  = new SelectList(db.Courses, "CourseID", "CourseName", enrollment.CourseID);
     ViewBag.TraineeID = new SelectList(db.trainees, "TraineeID", "TraineeName", enrollment.TraineeID);
     return(View(enrollment));
 }
 public ActionResult Edit([Bind(Include = "enrollmentid,courseid,studentid,grade")] enrollment enrollment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(enrollment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.courseid  = new SelectList(db.courses, "courseid", "title", enrollment.courseid);
     ViewBag.studentid = new SelectList(db.students, "studentid", "lastname", enrollment.studentid);
     return(View(enrollment));
 }
 public EnrollmentViewModel(enrollment en)
 {
     if (en != null)
     {
         this.Id        = en.Id;
         this.Date      = en.Date;
         this.Status    = en.Status;
         this.OfferId   = en.OfferId;
         this.StudentId = en.StudentId;
         this.Offered   = new OfferedViewModel(en.offered);
     }
 }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "enrollmentID,studentID,courseID")] enrollment enrollment)
        {
            if (ModelState.IsValid)
            {
                db.enrollments.Add(enrollment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.courseID  = new SelectList(db.courses, "courseID", "title", enrollment.courseID);
            ViewBag.studentID = new SelectList(db.students, "studentID", "firstName", enrollment.studentID);
            return(View(enrollment));
        }
        // GET: Enrollment/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            enrollment enrollment = db.enrollments.Find(id);

            if (enrollment == null)
            {
                return(HttpNotFound());
            }
            return(View(enrollment));
        }
        // GET: Enrollment/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            enrollment enrollment = db.enrollments.Find(id);

            if (enrollment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CourseID  = new SelectList(db.Courses, "CourseID", "CourseName", enrollment.CourseID);
            ViewBag.TraineeID = new SelectList(db.trainees, "TraineeID", "TraineeName", enrollment.TraineeID);
            return(View(enrollment));
        }
        // GET: enrollment/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            enrollment enrollment = db.enrollments.Find(id);

            if (enrollment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.courseid  = new SelectList(db.courses, "courseid", "title", enrollment.courseid);
            ViewBag.studentid = new SelectList(db.students, "studentid", "lastname", enrollment.studentid);
            return(View(enrollment));
        }
Esempio n. 10
0
        public void AddEnrollment(string studentId, int scheduleId, ref List<string> errors)
        {
            var db_Enrollment = new enrollment();

            try
            {
                db_Enrollment.student_id = studentId;
                db_Enrollment.schedule_id = scheduleId;
                db_Enrollment.grade = string.Empty;
                this.context.enrollments.Add(db_Enrollment);
                this.context.SaveChanges();
            }
            catch (Exception e)
            {
                errors.Add("Error occured in EnrollmentRepository.AddEnrollment: " + e);
            }
        }
Esempio n. 11
0
        public void AssignGradeToStudent(Schedule schedule, string studentId, int instructorId, string grade, ref List<string> errors)
        {
            var db_enrollment = new enrollment();
            int scheduleId;

            try
            {
                scheduleId = this.context.course_schedule.Where(
                    y => y.quarter == schedule.Quarter && y.year == int.Parse(schedule.Year) &&
                    y.instructor_id == instructorId).Select(x => x.schedule_id).First();
                db_enrollment = this.context.enrollments.Where(x => x.student_id == studentId && x.schedule_id == scheduleId).First();
                db_enrollment.grade = grade;
                this.context.SaveChanges();
            }
            catch (Exception e)
            {
                errors.Add("Error occured in InstructorRepository.AssignGradeToStudent: " + e);
            }
        }
 public void updateEnrollment(enrollment u)
 {
     new EnrollmentRepository().updateenrollment(u);
 }
 public void addEnrollment(enrollment u)
 {
     new EnrollmentRepository().addenrollment(u);
 }
Esempio n. 14
0
        public void UpdateEnrollment(Enrollment er, ref List<string> errors)
        {
            var db_Enrollment = new enrollment();

            try
            {
                db_Enrollment = this.context.enrollments.Where(x => x.schedule_id == er.ScheduleId && x.student_id == er.StudentId).First();
                db_Enrollment.grade = er.Grade;
                this.context.SaveChanges();
            }
            catch (Exception e)
            {
                errors.Add("Error occured in EnrollmentRepository.AddEnrollment: " + e);
            }
        }
Esempio n. 15
0
        public void RemoveEnrollment(string studentId, int scheduleId, ref List<string> errors)
        {
            var db_enrollment = new enrollment();

            try
            {
                db_enrollment = this.context.enrollments.Find(studentId, scheduleId);
                this.context.enrollments.Remove(db_enrollment);
                this.context.SaveChanges();
            }
            catch (Exception e)
            {
                errors.Add("Error: " + e);
            }
        }
 public ActionResult EditEnrollment(enrollment e)
 {
     new EnrollmentService().updateEnrollment(e);
     return(RedirectToAction("ViewEnrollments"));
 }
Esempio n. 17
0
        public Enrollment GetEnrollmentDetail(string studentId, int scheduleId, ref List<string> errors)
        {
            var db_Enrollment = new enrollment();
            var poco = new Enrollment();

            try
            {
                db_Enrollment = this.context.enrollments.Where(x => x.schedule_id == scheduleId && x.student_id == studentId).First();
                poco.StudentId = db_Enrollment.student_id;
                poco.ScheduleId = db_Enrollment.schedule_id;
                poco.Grade = db_Enrollment.grade;
            }
            catch (Exception e)
            {
                errors.Add("Error occured in EnrollmentRepository.AddEnrollment: " + e);
            }

            return poco;
        }