public ActionResult Edit(EditCalendarModel model)
        {
            try
            {
                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" };

                model.AttendeesAutoComplete = AutoCompleteID;
                model.EmployeeID = EmployeeID;
                model.appoingmentType = AppointmentType;
                model._campus = list;

                if (ModelState.IsValid)
                {
                    DateTime date1 = DateTime.Parse(model.startTime);
                    TimeSpan time1 = new TimeSpan(date1.Hour, date1.Minute, date1.Second);
                    DateTime date2 = DateTime.Parse(model.endTime);
                    TimeSpan time2 = new TimeSpan(date2.Hour, date2.Minute, date2.Second);
                    DateTime today1 = model.appointment.starttime;
                    today1 = today1.Add(time1);
                    DateTime today2 = model.appointment.endtime.Date;
                    today2 = today2.Add(time2);
                    model.appointment.starttime = today1;
                    model.appointment.endtime = today2;
                    db.appointments.Attach(model.appointment);
                    db.ObjectStateManager.ChangeObjectState(model.appointment, EntityState.Modified);
                    db.SaveChanges();

                    EditEmail(model.appointment);

                    return RedirectToAction("Details", "Calendar", new { id = model.appointment.appointmentid });
                }
            }
            catch (Exception ex)
            {
                return View(model);
            }

            return View(model);
        }
        /// <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);
        }