/// <summary> /// not complete still needs to be re-written /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Edit(Guid id) { appointment appointment = db.appointments.Single(i => i.appointmentid == id); IEnumerable<Attendee> Attendee = db.Attendees.Where(i => i.appointmentid == id); List<CalendarDetailsAttendees> Attendees = new List<CalendarDetailsAttendees>(); foreach (Attendee attend in Attendee) { student student = db.students.SingleOrDefault(s => s.studentid == attend.attendee1); employee employee = db.employees.SingleOrDefault(e => e.employeeid == attend.attendee1); CalendarDetailsAttendees DetailAttendees = new CalendarDetailsAttendees() { Attendees = attend, Student = student, Emplployee = employee }; if (student != null) { program prog = db.programs.Single(p => p.programcode == student.programcode); DetailAttendees.StudFaculty = prog.faculty; } Attendees.Add(DetailAttendees); } IEnumerable<campu> campus = db.campus; List<String> list = new List<String>(); foreach (campu camp in campus) { list.Add(camp.cname); } IEnumerable<student> students = db.students; List<AutoCompletePOCO> AutoCompleteID = new List<AutoCompletePOCO>(); foreach (student stud in students) { AutoCompletePOCO poco = new AutoCompletePOCO() { value = stud.fname + " " + stud.lname + " (" + stud.studentid + ")", Label = stud.fname + " " + stud.lname + " (" + stud.studentid + ")", Email = stud.email, Role = "Student" }; AutoCompleteID.Add(poco); } IEnumerable<employee> employees = db.employees; List<AutoCompletePOCO> EmployeeID = new List<AutoCompletePOCO>(); foreach (employee emp in employees) { AutoCompletePOCO poco = new AutoCompletePOCO() { value = emp.fname + " " + emp.lname + " (" + emp.employeeid + ")", Label = emp.fname + " " + emp.lname + " (" + emp.employeeid + ")", Email = emp.email, Role = emp.role }; AutoCompleteID.Add(poco); EmployeeID.Add(poco); } String[] AppointmentType = new String[3] { "Advisement", "Personal", "Office" }; EditCalendarModel model = new EditCalendarModel() { appointment = appointment, Attendees = Attendees, chair = db.employees.Single(emp => emp.employeeid == appointment.employeeid), appoingmentType = AppointmentType, _campus = list, startTime = appointment.starttime.ToShortTimeString(), endTime = appointment.endtime.ToShortTimeString(), EmployeeID = EmployeeID, AttendeesAutoComplete = AutoCompleteID }; return View(model); }
/// <summary> /// populates the details page /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Details(Guid id) { appointment appointment = db.appointments.Single(i => i.appointmentid == id); IEnumerable<Attendee> Attendee = db.Attendees.Where(i => i.appointmentid == id); List<CalendarDetailsAttendees> Attendees = new List<CalendarDetailsAttendees>(); foreach (Attendee attend in Attendee) { student student = db.students.SingleOrDefault(s => s.studentid == attend.attendee1); employee employee = db.employees.SingleOrDefault(e => e.employeeid == attend.attendee1); CalendarDetailsAttendees DetailAttendees = new CalendarDetailsAttendees() { Attendees = attend, Student = student, Emplployee = employee }; if(student != null) { program prog = db.programs.Single(p => p.programcode == student.programcode); DetailAttendees.StudFaculty = prog.faculty; } Attendees.Add(DetailAttendees); } DetailsCalendarModel model = new DetailsCalendarModel() { appointment = appointment, Attendees = Attendees, chair = db.employees.Single(emp => emp.employeeid == appointment.employeeid) }; return View(model); }