public ActionResult Edit([Bind(Include = "EnrolmentID,Grade,EnrolmentComplete,StudentID")] Enrolment enrolment) { if (ModelState.IsValid) { db.Entry(enrolment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StudentID = new SelectList(db.Students, "StudentID", "FirstName", enrolment.StudentID); return(View(enrolment)); }
public ActionResult Edit([Bind(Include = "Id,EnrolmentDate,Grade,UserId,StudentId,UnitId")] Enrolment enrolment) { if (ModelState.IsValid) { db.Entry(enrolment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StudentId = new SelectList(db.StudentSet, "Id", "FirstName", enrolment.StudentId); ViewBag.UnitId = new SelectList(db.UnitSet, "Id", "UnitName", enrolment.UnitId); return(View(enrolment)); }
public ActionResult Edit([Bind(Include = "id,UnitAttemptStat,student_id,StuUnit_id")] Enrolment enrolment) { if (ModelState.IsValid) { db.Entry(enrolment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.student_id = new SelectList(db.Students, "id", "CourseTitle", enrolment.student_id); ViewBag.StuUnit_id = new SelectList(db.Units, "id", "UnitCode", enrolment.StuUnit_id); return(View(enrolment)); }
public ActionResult Edit([Bind(Include = "EnrollId,SiD,CourseId,EnrolmentYear,EnrolmentSemester,Grade")] Enrolment enrolment) { if (ModelState.IsValid) { db.Entry(enrolment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "CourseName", enrolment.CourseId); ViewBag.SiD = new SelectList(db.Students, "SiD", "Name", enrolment.SiD); return(View(enrolment)); }
public async Task <IActionResult> CreateEnrolment() { var model = new Enrolment(); var unitOfferings = await _enrolmentRepo.GetUnitOfferingListAsync(); var students = await _enrolmentRepo.GetStudentListAsync(); //employee logic here model.Student_List = students.ToList(); model.UnitOffering_List = unitOfferings.ToList(); return(View(model)); }
public ActionResult Edit([Bind(Include = "EnrolmentId,CourseId,StudentId,Grade")] Enrolment enrolment) { if (ModelState.IsValid) { db.Entry(enrolment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "Title", enrolment.CourseId); ViewBag.StudentId = new SelectList(db.Students, "Id", "Lastname", enrolment.StudentId); return(View(enrolment)); }
public IHttpActionResult PostEnrolment(Enrolment enrolment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Enrolments.Add(enrolment); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = enrolment.EnrolmentID }, enrolment)); }
public async Task <IActionResult> Create([Bind("EnrolId,CourseId,CourseDescription,EnrolmentYear,EnrolmentSemester,PreRequisite")] Enrolment enrolment) { if (ModelState.IsValid) { _context.Add(enrolment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.Course, "CourseId", "CourseId", enrolment.CourseId); return(View(enrolment)); }
public void AddEnrolment(int studentId, int courseId) { Student student = _ctx.Students.Find(studentId); Course course = _ctx.Courses.Find(courseId); var newEnrol = new Enrolment { StudentId = studentId, CourseId = courseId }; _ctx.Enrolments.Add(newEnrol); Save(); }
static void Main(string[] args) { using (var dbCtx = new CollegeContextEntities()) { List <Student> listing = dbCtx.Students.ToList(); foreach (Student s in listing) { Console.WriteLine($"Student is {s.FirstName} {s.LastName}"); } Console.WriteLine($"Done {listing.Count}"); } using (var dbCtx = new CollegeContextEntities()) { List <Course> listing = dbCtx.Courses.ToList(); foreach (Course c in listing) { Console.WriteLine($"Course is {c.Title} {c.Credits}"); } Console.WriteLine($"Done {listing.Count}"); } using (var dbCtx = new CollegeContextEntities()) { List <Enrolment> listing = dbCtx.Enrolments.ToList(); foreach (Enrolment e in listing) { Console.WriteLine($"Enrolment course is {e.Course.Title} and Student is {e.Student.FirstName} {e.Student.LastName}"); } Console.WriteLine($"Enrolment count is {listing.Count}"); } using (var dbCtx = new CollegeContextEntities()) { Course existingCourse = dbCtx.Courses.Where(x => x.id == 2).FirstOrDefault(); Student existingStudent = dbCtx.Students.Where(x => x.Id == 1).FirstOrDefault(); Enrolment newEnrolment = new Enrolment(); newEnrolment.Student = existingStudent; newEnrolment.Course = existingCourse; dbCtx.Enrolments.Add(newEnrolment); dbCtx.SaveChanges(); } }
public async Task <IActionResult> Create([Bind("Id,StudentId,CourseId,StartDate,EndDate")] Enrolment enrolment) { if (ModelState.IsValid) { _context.Add(enrolment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.Course, "Id", "Id", enrolment.CourseId); ViewData["StudentId"] = new SelectList(_context.Set <Student>(), "Id", "Id", enrolment.StudentId); return(View(enrolment)); }
public async Task <IActionResult> Create([Bind("EnrolId,TeamId,GradeId")] Enrolment enrolment) { if (ModelState.IsValid) { _context.Add(enrolment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GradeId"] = new SelectList(_context.Grade, "GradeId", "GradeId", enrolment.GradeId); ViewData["TeamId"] = new SelectList(_context.Teams, "TeamId", "TeamId", enrolment.TeamId); return(View(enrolment)); }
// GET: Enrolments/Create public ActionResult Create(String Id, String date) { if (null == date) { return(RedirectToAction("Index")); } Enrolment e = new Enrolment(); DateTime convertedDate = DateTime.Parse(date); e.Start = convertedDate; e.CourseId = int.Parse(Id); return(View(e)); }
public ActionResult Create(Enrolment enrolment) { if (ModelState.IsValid) { enrolment.SrudentCount = 0; enrolment.Status = "Available"; db.Enrolments.Add(enrolment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View("Index")); }
private void Validate(Enrolment enrolment) { ValidateBasic(enrolment); if (context.Enrolment.Any(_ => _.Id != enrolment.Id && _.SemesterId == enrolment.SemesterId && _.StudentId == enrolment.StudentId && _.CourseId == enrolment.CourseId) ) { throw new ValidationException("Selected student is already enrolled on this course in selected semester."); } }
public ActionResult Delete(int id) { Enrolment enrolment = db.Enrolments.Find(id); var enrolledStudent = db.EnrolledStudents.Where(m => m.TutorialId == id).ToList(); foreach (var student in enrolledStudent) { DeleteStudent(student.Id); } db.Enrolments.Remove(enrolment); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult DeleteEnrolment(int id) { Enrolment enrolment = db.Enrolments.Find(id); if (enrolment == null) { return(NotFound()); } db.Enrolments.Remove(enrolment); db.SaveChanges(); return(Ok(enrolment)); }
public Student CreateEnrolment(int studentId, int classId) { var student = _studentService.GetStudentById(studentId); var classToEnrolInto = _classService.GetClassById(classId); var enrolment = new Enrolment { Student = student, Class = classToEnrolInto }; _enrolmentRepository.CreateEnrolment(enrolment); return(student); }
public void Enrolment_FinalGrade_GetsAndSets() { // Arrange FinalGrade expected = FinalGrade.C; //Enrolment enrolment = new Enrolment(new Person(), new Section(), 9); Enrolment enrolment = new Enrolment(new Student(), new Section(), 9); // Act enrolment.FinalGrade = FinalGrade.C; // Assert FinalGrade actual = enrolment.FinalGrade; Assert.AreEqual(expected, actual); }
public async Task <IActionResult> Create([Bind("CourseID,CI,Date")] Enrolment enrolment) { if (ModelState.IsValid) { _context.Add(enrolment); await _context.SaveChangesAsync(); _toastNotification.AddSuccessToastMessage("Se inscribio al empleado a curso exitosamente"); return(RedirectToAction(nameof(Index))); } ViewData["CourseID"] = new SelectList(_context.Course, "CourseID", "Name", enrolment.CourseID); ViewData["CI"] = new SelectList(_context.Employee, "CI", "CI", enrolment.CI); return(View(enrolment)); }
public ActionResult Create([Bind(Include = "Id,CourseId,Start")] Enrolment enrolment) { foreach (Enrolment enl in db.Enrolments.ToList()) { var c = User.Identity.GetUserId(); if (enl.Start == enrolment.Start && enl.UserId == c) { return(RedirectToAction("ErrorInforConstraint")); } } Boolean courseCheck = false; Boolean courseDateCheck = false; foreach (Course cou in db.Courses.ToList()) { if (cou.Id == enrolment.CourseId) { courseCheck = true; if (cou.Date == enrolment.Start) { courseDateCheck = true; } } } if (!courseCheck) { return(RedirectToAction("ErrorInforCourseId")); } if (!courseDateCheck) { return(RedirectToAction("ErrorInforDate")); } enrolment.UserId = User.Identity.GetUserId(); ModelState.Clear(); TryValidateModel(enrolment); if (ModelState.IsValid) { db.Enrolments.Add(enrolment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(enrolment)); }
// GET: Enrolments/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Enrolment enrolment = await db.Enrolments.FindAsync(id); if (enrolment == null) { return(HttpNotFound()); } return(View(enrolment)); }
// GET: Enrolments/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Enrolment enrolment = db.Enrolments.Find(id); if (enrolment == null) { return(HttpNotFound()); } return(View(enrolment)); }
public async Task <ActionResult> Edit([Bind(Include = "ID,PaymentReceived,PaymentDue,ChildID,ActivityID,PaymentID")] Enrolment enrolment) { if (ModelState.IsValid) { db.Entry(enrolment).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.ActivityID = new SelectList(db.Activities, "ID", "NameOfActivity", enrolment.ActivityID); ViewBag.ChildID = new SelectList(db.Children, "ID", "FirstName", enrolment.ChildID); //ViewBag.PaymentID = new SelectList(db.Payments, "ID", "PayeeName", enrolment.PaymentID); return(View(enrolment)); }
public Enrolment UpdEnrolment(Enrolment newEnrolment) { Enrolment rtEnrolment = null; try { _enrolmentDal.Update(newEnrolment); rtEnrolment = newEnrolment; } catch (RepositoryException ex) { throw ex; } return(rtEnrolment); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Enrolment = await _context.Enrolment.FirstOrDefaultAsync(m => m.EnrolmentID == id); if (Enrolment == null) { return(NotFound()); } return(Page()); }
public void Enrolment_Student_GetsAndSets() { // Arrange //Person expected = new Person("John", new DateTime(1999, 9, 9)); //Enrolment enrolment = new Enrolment(new Person(), new Section(), 9); Student expected = new Student("John", new DateTime(1999, 9, 9)); Enrolment enrolment = new Enrolment(new Student(), new Section(), 9); // Act enrolment.Student = expected; // Assert Person actual = enrolment.Student; Assert.AreSame(expected, actual); }
private void btnSearchCourses_Click(object sender, EventArgs e) { String progCode = cmbProgram.GetItemText(cmbProgram.SelectedItem); String semCode = cbxSemester.GetItemText(cbxSemester.SelectedItem); String type = cbxType.GetItemText(cbxType.SelectedItem); List <Enrolment> offerlist = Enrolment.getCourses(progCode, semCode, type); for (int i = 0; i < offerlist.Count; i++) { Enrolment offer = offerlist[i]; String value = offer.Code; lbAvailableCourses.Items.Add(value); lbName.Items.Add(offer.Name); } }
public async Task <IActionResult> CreateEnrolment(Enrolment model) { try { if (await _enrolmentRepo.CreateEnrolmentAsync(model) >= 0) { return(RedirectToAction(nameof(ViewEnrolments))); } } catch (Exception ex) { Console.WriteLine(ex); } return(View(model)); }
public ActionResult Edit([Bind(Include = "Id,Cid,Rating")] Enrolment enrolment) { enrolment.StuId = User.Identity.GetUserId(); ModelState.Clear(); TryValidateModel(enrolment); if (ModelState.IsValid) { db.Entry(enrolment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Cid = new SelectList(db.Lesson, "Id", "Name", enrolment.Cid); return(View(enrolment)); }