public ViewResult RsvpForm(GuestResponsecs guestResponsecs) { //Todo: store response from guest if (ModelState.IsValid) { Repository.AddResponse(guestResponsecs); var AllClasses = new List <ClassesModel> { new ClassesModel("physical_database_design_&_opt", "Fall", 5), new ClassesModel("comp_system_principles_2", "Fall", 3), new ClassesModel("fund_of_software_engineerring", "Spring", 3), new ClassesModel("data_structures_and_algorithms", "Spring", 5), new ClassesModel("security_in_computing", "Winter", 3), new ClassesModel("sw_architecture_and_design_1", "Winter", 3) }; var viewModel = new StudentClassesViewModel { Student = guestResponsecs, ClassesAvailable = AllClasses }; return(View("Thanks", viewModel)); } else { //there is a validation error return(View()); } }
public async Task <StudentClassesViewModel> GetAllClasses(string user) { var classes = await _db.Classes.ToListAsync(); var student = await _db.Students.FirstOrDefaultAsync(x => x.Mail == user); var studentClassesViewModel = new StudentClassesViewModel { StudentClasses = classes, Student = student }; return(studentClassesViewModel); }
//GET: Students/StudentClasses/5 //Use the StudentClassesViewModel to create a view for the Student's classes public async Task <IActionResult> StudentClasses(int id) { string connectionString = @"Data Source=/Users/toby/g45/capstone/bin/Debug/netcoreapp1.1/findAMentor.db;"; SqliteConnection conn; List <StudentClassesViewModel> modelList = new List <StudentClassesViewModel>(); string sql = "select sub.ID subjectID, sub.name, sub.category, studSubs.studentID, studSubs.status, " + "stud.first_name, stud.last_name, stud.email, stud.phone " + "from subject sub " + "inner join studentSubjects studSubs " + "on sub.ID = studSubs.subjectID " + "inner join Student stud " + "on stud.ID = studSubs.studentID " + "where stud.ID = " + id; try { conn = new SqliteConnection(connectionString); conn.Open(); SqliteCommand command = new SqliteCommand(sql, conn); SqliteDataReader reader = command.ExecuteReader(); while (reader.Read()) { StudentClassesViewModel scvm = new StudentClassesViewModel(); //student = MapStudent(reader, student); scvm.first_name = reader["first_name"].ToString(); scvm.last_name = reader["last_name"].ToString(); scvm.category = reader["category"].ToString(); scvm.name = reader["name"].ToString(); scvm.status = reader["status"].ToString(); ViewBag.studentName = scvm.first_name; modelList.Add(scvm); } ViewBag.Categories = new SelectList(GetCategories(conn)); command.Dispose(); } catch (Exception e) { Console.WriteLine("Exception = " + e.Message); } return(View(modelList)); }
public ActionResult Classes() { UnitOfWork uow = new UnitOfWork(); //List<StudentClasses> sc = uow.StudentRepository.GetClasses(Session["UserId"].ToString(), (int)ClassJoinStatus.Approved); List <StudentClasses> sc = uow.StudentRepository.GetClasses(Session["UserId"].ToString()); StudentClassesViewModel model = new StudentClassesViewModel(); //model.Pending = sc.Where(e => e.ClassDate > DateTime.Now && (e.RequestStatus == (int)ClassJoinStatus.Pending || e.RequestStatus == (int)ClassJoinStatus.Rejected)).ToList(); model.Pending = sc.Where(e => (e.RequestStatus == (int)ClassJoinStatus.Pending || e.RequestStatus == (int)ClassJoinStatus.Invited || e.RequestStatus == (int)ClassJoinStatus.Rejected)).ToList(); model.Upcoming = sc.Where(e => e.ClassDate > DateTime.Now && (e.RequestStatus == (int)ClassStatus.Approved || e.ClassStatus == (int)ClassStatus.OfferAccepted)).ToList(); model.Past = sc.Where(e => e.ClassDate < DateTime.Now && e.RequestStatus != (int)ClassJoinStatus.Rejected).ToList(); model.Cancelled = sc.Where(e => e.ClassStatus == (int)ClassStatus.Cancelled).ToList(); //model.Recorded = sc.Where(e => e.ClassDate < DateTime.Now && e.ClassStatus != (int)ClassStatus.Cancelled && e.Record == true).ToList(); return(View(model)); }
public ActionResult Classes(int id) { var viewModel = new StudentClassesViewModel(id); return(View(viewModel)); }