private void Fixupappointment(appointment previousValue) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.Attendees.Contains(this)) { previousValue.Attendees.Remove(this); } if (appointment != null) { if (!appointment.Attendees.Contains(this)) { appointment.Attendees.Add(this); } appointmentid = appointment.appointmentid; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("appointment") && (ChangeTracker.OriginalValues["appointment"] == appointment)) { ChangeTracker.OriginalValues.Remove("appointment"); } else { ChangeTracker.RecordOriginalValue("appointment", previousValue); } if (appointment != null && !appointment.ChangeTracker.ChangeTrackingEnabled) { appointment.StartTracking(); } } }
/// <summary> /// sends an email to the attendees informing that they have been invited to an series of appointments /// </summary> /// <param name="emp"></param> /// <param name="appointment"></param> private void EmailAttendeesSeries(employee emp, appointment appointment) { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient(MAIL_SMTP); IEnumerable<appointment> appointments = db.appointments.Where(a => a.repeating == appointment.repeating).OrderBy(a => a.starttime); DateTime start = appointments.First().starttime; DateTime end = appointments.OrderByDescending(a => a.starttime).First().starttime; employee chair = db.employees.Single(e => e.employeeid == appointment.employeeid); IEnumerable<Attendee> Attendees = db.Attendees.Where(attend => attend.appointmentid == appointment.appointmentid); String EmailTo = chair.email; foreach (Attendee Attendee in Attendees) { student student = db.students.SingleOrDefault(stud => stud.studentid == Attendee.attendee1); if (student != null) { EmailTo += ", " + student.email; } else { employee employee = db.employees.Single(e => e.employeeid == Attendee.attendee1); EmailTo += ", " + employee.email; } } mail.From = new MailAddress(MAIL_ADDRESS); mail.To.Add(EmailTo); mail.Subject = "Appointment Invitation From " + emp.fname + " " + emp.lname; mail.Body = "You have been requested to attend an " + appointment.appointmenttype.Trim() + " appointment regarding " + appointment.subject + " starting on " + start + " to " + end + " and the appointments will take place at " + appointment.cname + ". The chair for the appointment will be " + chair.fname + " " + chair.lname + ", please contact him/her regarding any further details at " + chair.email + " or " + chair.phonenum + "."; if (appointment.description != null) { mail.Body += "\n\nDescription Included: \n" + appointment.description; } mail.Body += "\n\nThis is an automated message please to do not respond to this email."; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential(MAIL_ADDRESS, MAIL_PASS); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); }
public ActionResult Create(CreateAppointmentRequestModel model) { try { if (ModelState.IsValid) { //deconstructs the string down to a collection of student IDs List<String> attendeesID = new List<string>(); if (model.Attendees != null) { String EmployeeID = model.Attendees; String[] attendees = EmployeeID.Split(','); for (int i = 0; i < attendees.Count() - 1; i++) { if (i != 0) { String id = attendees[i].Remove(0, attendees[i].Length - 10); attendeesID.Add(id.Remove(id.Length - 1)); } else { String id = attendees[i].Remove(0, attendees[i].Length - 10); attendeesID.Add(id.Remove(id.Length - 1)); } } } model._appointment.employeeid = model._appointment.employeeid.Remove(0, model._appointment.employeeid.Length - 10); model._appointment.employeeid = model._appointment.employeeid.Remove(model._appointment.employeeid.Length - 1); model.repeatingType = new String[] { "Not Repeating", "Daily (Business Days)", "Weekly", "Bi-Weekly", "Monthly", "Yearly" }; 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> EmpAutoCom = 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); EmpAutoCom.Add(poco); } model.AttendeesAutoComplete = AutoCompleteID; model.EmployeeID = EmpAutoCom; String[] AppointmentType = new String[3] { "Advisement", "Personal", "Office" }; model._campus = list; model.appoingmentType = AppointmentType; 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); model._appointment.starttime = model._appointment.starttime.Add(time1); model._appointment.endtime = model._appointment.endtime.Add(time2); //based on whether the appointment is repeating will use one fo the following sets of code to create the appoinment/series of appointments if (model.repeating.Trim().Equals("Not Repeating")) { model._appointment.appointmentid = Guid.NewGuid(); db.appointments.AddObject(model._appointment); db.SaveChanges(); if (attendeesID.Count > 0) { List<Attendee> Attendee = new List<Models.Attendee>(); foreach (String id in attendeesID) { Attendee attendee = new Attendee() { id = Guid.NewGuid(), appointmentid = model._appointment.appointmentid, attendee1 = id }; student stud = db.students.SingleOrDefault(s => s.studentid == id); if (stud != null) { attendee.confirmed = true; } Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attendee.attendee1 && a.appointmentid == attendee.appointmentid); if (check == null) { if (!attendee.attendee1.Equals(model._appointment.employeeid)) Attendee.Add(attendee); } } foreach (Attendee attend in Attendee) { Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attend.attendee1 && a.appointmentid == attend.appointmentid); if (check == null) db.Attendees.AddObject(attend); db.SaveChanges(); } } } else if (model.repeating.Trim().Equals("Daily (Business Days)")) { DateTime endRepeatingDate = model._appointment.endtime; model._appointment.endtime = model._appointment.starttime; model._appointment.endtime = model._appointment.endtime.Add(-time1); model._appointment.endtime = model._appointment.endtime.Add(time2); model._appointment.repeating = Guid.NewGuid(); while (model._appointment.starttime.Date <= endRepeatingDate.Date) { if ((model._appointment.starttime.DayOfWeek != DayOfWeek.Saturday) && (model._appointment.starttime.DayOfWeek != DayOfWeek.Sunday)) { appointment appointment = new appointment() { allday = model._appointment.allday, appointmenttype = model._appointment.appointmenttype, cname = model._appointment.cname, description = model._appointment.description, employeeid = model._appointment.employeeid, endtime = model._appointment.endtime, repeating = model._appointment.repeating, starttime = model._appointment.starttime, subject = model._appointment.subject }; appointment.appointmentid = Guid.NewGuid(); model._appointment.appointmentid = appointment.appointmentid; db.appointments.AddObject(appointment); db.SaveChanges(); if (attendeesID.Count > 0) { List<Attendee> Attendee = new List<Models.Attendee>(); foreach (String id in attendeesID) { Attendee attendee = new Attendee() { id = Guid.NewGuid(), appointmentid = appointment.appointmentid, attendee1 = id }; student stud = db.students.SingleOrDefault(s => s.studentid == id); if (stud != null) { attendee.confirmed = true; } Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attendee.attendee1 && a.appointmentid == attendee.appointmentid); if (check == null) { if (!attendee.attendee1.Equals(model._appointment.employeeid)) Attendee.Add(attendee); } } foreach (Attendee attend in Attendee) { Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attend.attendee1 && a.appointmentid == attend.appointmentid); if (check == null) db.Attendees.AddObject(attend); db.SaveChanges(); } } } model._appointment.starttime = model._appointment.starttime.AddDays(1); model._appointment.endtime = model._appointment.endtime.AddDays(1); } } else if (model.repeating.Trim().Equals("Weekly")) { DateTime endRepeatingDate = model._appointment.endtime; model._appointment.endtime = model._appointment.starttime; model._appointment.endtime = model._appointment.endtime.Add(-time1); model._appointment.endtime = model._appointment.endtime.Add(time2); model._appointment.repeating = Guid.NewGuid(); while (model._appointment.starttime.Date <= endRepeatingDate.Date) { appointment appointment = new appointment() { allday = model._appointment.allday, appointmenttype = model._appointment.appointmenttype, cname = model._appointment.cname, description = model._appointment.description, employeeid = model._appointment.employeeid, endtime = model._appointment.endtime, repeating = model._appointment.repeating, starttime = model._appointment.starttime, subject = model._appointment.subject }; appointment.appointmentid = Guid.NewGuid(); model._appointment.appointmentid = appointment.appointmentid; db.appointments.AddObject(appointment); db.SaveChanges(); if (attendeesID.Count > 0) { List<Attendee> Attendee = new List<Models.Attendee>(); foreach (String id in attendeesID) { Attendee attendee = new Attendee() { id = Guid.NewGuid(), appointmentid = appointment.appointmentid, attendee1 = id }; student stud = db.students.SingleOrDefault(s => s.studentid == id); if (stud != null) { attendee.confirmed = true; } Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attendee.attendee1 && a.appointmentid == attendee.appointmentid); if (check == null) { if (!attendee.attendee1.Equals(model._appointment.employeeid)) Attendee.Add(attendee); } } foreach (Attendee attend in Attendee) { Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attend.attendee1 && a.appointmentid == attend.appointmentid); if (check == null) db.Attendees.AddObject(attend); db.SaveChanges(); } } model._appointment.starttime = model._appointment.starttime.AddDays(7); model._appointment.endtime = model._appointment.endtime.AddDays(7); } } else if (model.repeating.Trim().Equals("Bi-Weekly")) { DateTime endRepeatingDate = model._appointment.endtime; model._appointment.endtime = model._appointment.starttime; model._appointment.endtime = model._appointment.endtime.Add(-time1); model._appointment.endtime = model._appointment.endtime.Add(time2); model._appointment.repeating = Guid.NewGuid(); while (model._appointment.starttime.Date <= endRepeatingDate.Date) { appointment appointment = new appointment() { allday = model._appointment.allday, appointmenttype = model._appointment.appointmenttype, cname = model._appointment.cname, description = model._appointment.description, employeeid = model._appointment.employeeid, endtime = model._appointment.endtime, repeating = model._appointment.repeating, starttime = model._appointment.starttime, subject = model._appointment.subject }; appointment.appointmentid = Guid.NewGuid(); model._appointment.appointmentid = appointment.appointmentid; db.appointments.AddObject(appointment); db.SaveChanges(); if (attendeesID.Count > 0) { List<Attendee> Attendee = new List<Models.Attendee>(); foreach (String id in attendeesID) { Attendee attendee = new Attendee() { id = Guid.NewGuid(), appointmentid = appointment.appointmentid, attendee1 = id }; student stud = db.students.SingleOrDefault(s => s.studentid == id); if (stud != null) { attendee.confirmed = true; } Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attendee.attendee1 && a.appointmentid == attendee.appointmentid); if (check == null) { if (!attendee.attendee1.Equals(model._appointment.employeeid)) Attendee.Add(attendee); } } foreach (Attendee attend in Attendee) { Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attend.attendee1 && a.appointmentid == attend.appointmentid); if (check == null) db.Attendees.AddObject(attend); db.SaveChanges(); } } model._appointment.starttime = model._appointment.starttime.AddDays(14); model._appointment.endtime = model._appointment.endtime.AddDays(14); } } else if (model.repeating.Trim().Equals("Monthly")) { DateTime endRepeatingDate = model._appointment.endtime; model._appointment.endtime = model._appointment.starttime; model._appointment.endtime = model._appointment.endtime.Add(-time1); model._appointment.endtime = model._appointment.endtime.Add(time2); model._appointment.repeating = Guid.NewGuid(); while (model._appointment.starttime.Date <= endRepeatingDate.Date) { appointment appointment = new appointment() { allday = model._appointment.allday, appointmenttype = model._appointment.appointmenttype, cname = model._appointment.cname, description = model._appointment.description, employeeid = model._appointment.employeeid, endtime = model._appointment.endtime, repeating = model._appointment.repeating, starttime = model._appointment.starttime, subject = model._appointment.subject }; appointment.appointmentid = Guid.NewGuid(); model._appointment.appointmentid = appointment.appointmentid; db.appointments.AddObject(appointment); db.SaveChanges(); if (attendeesID.Count > 0) { List<Attendee> Attendee = new List<Models.Attendee>(); foreach (String id in attendeesID) { Attendee attendee = new Attendee() { id = Guid.NewGuid(), appointmentid = appointment.appointmentid, attendee1 = id }; student stud = db.students.SingleOrDefault(s => s.studentid == id); if (stud != null) { attendee.confirmed = true; } Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attendee.attendee1 && a.appointmentid == attendee.appointmentid); if (check == null) { if (!attendee.attendee1.Equals(model._appointment.employeeid)) Attendee.Add(attendee); } } foreach (Attendee attend in Attendee) { Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attend.attendee1 && a.appointmentid == attend.appointmentid); if (check == null) db.Attendees.AddObject(attend); db.SaveChanges(); } } model._appointment.starttime = model._appointment.starttime.AddMonths(1); model._appointment.endtime = model._appointment.endtime.AddMonths(1); } } else if (model.repeating.Trim().Equals("Yearly")) { DateTime endRepeatingDate = model._appointment.endtime; model._appointment.endtime = model._appointment.starttime; model._appointment.endtime = model._appointment.endtime.Add(-time1); model._appointment.endtime = model._appointment.endtime.Add(time2); model._appointment.repeating = Guid.NewGuid(); while (model._appointment.starttime.Date <= endRepeatingDate.Date) { appointment appointment = new appointment() { allday = model._appointment.allday, appointmenttype = model._appointment.appointmenttype, cname = model._appointment.cname, description = model._appointment.description, employeeid = model._appointment.employeeid, endtime = model._appointment.endtime, repeating = model._appointment.repeating, starttime = model._appointment.starttime, subject = model._appointment.subject }; appointment.appointmentid = Guid.NewGuid(); model._appointment.appointmentid = appointment.appointmentid; db.appointments.AddObject(appointment); db.SaveChanges(); if (attendeesID.Count > 0) { List<Attendee> Attendee = new List<Models.Attendee>(); foreach (String id in attendeesID) { Attendee attendee = new Attendee() { id = Guid.NewGuid(), appointmentid = appointment.appointmentid, attendee1 = id }; student stud = db.students.SingleOrDefault(s => s.studentid == id); if (stud != null) { attendee.confirmed = true; } Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attendee.attendee1 && a.appointmentid == attendee.appointmentid); if (check == null) { if (!attendee.attendee1.Equals(model._appointment.employeeid)) Attendee.Add(attendee); } } foreach (Attendee attend in Attendee) { Attendee check = db.Attendees.SingleOrDefault(a => a.attendee1 == attend.attendee1 && a.appointmentid == attend.appointmentid); if (check == null) db.Attendees.AddObject(attend); db.SaveChanges(); } } model._appointment.starttime = model._appointment.starttime.AddYears(1); model._appointment.endtime = model._appointment.endtime.AddYears(1); } } employee creator = db.employees.Single(emp => emp.employeeid == User.Identity.Name); if (model.repeating.Trim().Equals("Not Repeating")) { ConfirmationEmail(creator, model._appointment); } else { ConfirmationEmailSeries(creator, model._appointment); } if (model.emailAll) { if (model.repeating.Trim().Equals("Not Repeating")) { EmailAttendees(creator, model._appointment); } else { EmailAttendeesSeries(creator, model._appointment); } } return RedirectToAction("Details/" + model._appointment.appointmentid, "Calendar"); } return View(model); } catch (Exception ex) { return View(model); } }
/// <summary> /// Emails all attenddees that an attendee has declined an a series of appointments /// </summary> /// <param name="id"></param> /// <param name="appointment"></param> private void EmailAttendeesDeclineSeries(String id, appointment appointment) { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient(MAIL_SMTP); String fname = ""; String lname = ""; employee i = db.employees.SingleOrDefault(e => e.employeeid == id); if (i != null) { fname = i.fname; lname = i.lname; } else { student s = db.students.SingleOrDefault(c => c.studentid == id); fname = s.fname; lname = s.lname; } IEnumerable<appointment> appointments = db.appointments.Where(a => a.repeating == appointment.repeating).OrderBy(a => a.starttime); DateTime start = appointments.First().starttime; DateTime end = appointments.OrderByDescending(a => a.starttime).First().starttime; employee chair = db.employees.Single(e => e.employeeid == appointment.employeeid); IEnumerable<Attendee> Attendees = db.Attendees.Where(attend => attend.appointmentid == appointment.appointmentid); String EmailTo = chair.email; foreach (Attendee Attendee in Attendees) { student student = db.students.SingleOrDefault(stud => stud.studentid == Attendee.attendee1); if (student != null) { EmailTo += ", " + student.email; } else { employee employee = db.employees.Single(e => e.employeeid == Attendee.attendee1); EmailTo += ", " + employee.email; } } mail.From = new MailAddress(MAIL_ADDRESS); mail.To.Add(EmailTo); mail.Subject = fname + " " + lname + " has Declined the Appointment Series"; mail.Body = fname + " " + lname + " has declined the " + appointment.appointmenttype.Trim() + " appointment series regarding " + appointment.subject + " at " + start + " to " + end + " and the appointment will take place at " + appointment.cname + ". The chair for the appointment will be " + chair.fname + " " + chair.lname + ", please contact him/her regarding any further details at " + chair.email + " or " + chair.phonenum + "."; mail.Body += "\n\nThis is an automated message please to do not respond to this email."; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential(MAIL_ADDRESS, MAIL_PASS); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); }
private void EditEmail(appointment appointment) { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient(MAIL_SMTP); employee chair = db.employees.Single(e => e.employeeid == appointment.employeeid); IEnumerable<Attendee> Attendees = db.Attendees.Where(attend => attend.appointmentid == appointment.appointmentid); String EmailTo = chair.email; foreach (Attendee Attendee in Attendees) { student student = db.students.SingleOrDefault(stud => stud.studentid == Attendee.attendee1); if (student != null) { EmailTo += ", " + student.email; } else { employee employee = db.employees.Single(e => e.employeeid == Attendee.attendee1); EmailTo += ", " + employee.email; } } mail.From = new MailAddress(MAIL_ADDRESS); mail.To.Add(EmailTo); mail.Subject = "Your Appointment Has Been Changed"; mail.Body = "Your " + appointment.appointmenttype.Trim() + " appointment regarding " + appointment.subject + " at " + appointment.starttime.ToString() + " to " + appointment.endtime.ToString() + " that is to take place at " + appointment.cname + " has been edited. If you would like to inquire further please view the changes within the system or contact " + chair.fname + " " + chair.lname + " regarding any further details at " + chair.email + " or " + chair.phonenum + "."; mail.Body += "\n\nThis is an automated message please to do not respond to this email."; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential(MAIL_ADDRESS, MAIL_PASS); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); }
/// <summary> /// sends an email to the creater of the appointment confirming that the the series appointments have been created. /// </summary> /// <param name="employee"></param> /// <param name="appointment"></param> private void ConfirmationEmailSeries(employee employee, appointment appointment) { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient(MAIL_SMTP); IEnumerable<appointment> appointments = db.appointments.Where(a => a.repeating == appointment.repeating).OrderBy(a => a.starttime); DateTime start = appointments.First().starttime; DateTime end = appointments.OrderByDescending(a => a.starttime).First().starttime; mail.From = new MailAddress(MAIL_ADDRESS); mail.To.Add(employee.email); mail.Subject = "Appointment Confirmation for " + employee.fname + " " + employee.lname; mail.Body = "You have successfully created an series of " + appointment.appointmenttype.Trim() + " appointments starting on " + start + " to " + end + " and the appointment will take place at " + appointment.cname + "."; mail.Body += "\n\nThis is an automated message please to do not respond to this email."; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential(MAIL_ADDRESS, MAIL_PASS); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); }
/// <summary> /// Sends an email to the creator of the appointment confirming that the appointment has been created /// </summary> /// <param name="employee"></param> /// <param name="appointment"></param> private void ConfirmationEmail(employee employee, appointment appointment) { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient(MAIL_SMTP); mail.From = new MailAddress(MAIL_ADDRESS); mail.To.Add(employee.email); mail.Subject = "Appointment Confirmation for " + employee.fname + " " + employee.lname; mail.Body = "You have successfully created an " + appointment.appointmenttype.Trim() + " appointment at " + appointment.starttime.ToString() + " to " + appointment.endtime.ToString() + " and the appointment will take place at " + appointment.cname + "."; mail.Body += "\n\nThis is an automated message please to do not respond to this email."; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential(MAIL_ADDRESS, MAIL_PASS); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); }
/// <summary> /// populates the reate page /// </summary> /// <param name="id"></param> /// <param name="subject"></param> /// <returns></returns> public ActionResult Create(String id, String subject) { appointment appointment = new appointment() { starttime = DateTime.Now, endtime = DateTime.Now.AddHours(.5) }; employee employee = db.employees.Single(emp => emp.employeeid == User.Identity.Name); appointment.employeeid = employee.fname + " " + employee.lname + " (" + employee.employeeid + ")"; if (subject != null) appointment.subject = subject; 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" }; CreateAppointmentRequestModel model = new CreateAppointmentRequestModel() { _appointment = appointment, _campus = list, AttendeesAutoComplete = AutoCompleteID, EmployeeID = EmployeeID, startTime = DateTime.Now.ToShortTimeString(), endTime = DateTime.Now.AddHours(.5).ToShortTimeString(), appoingmentType = AppointmentType, emailAll = true, repeatingType = new String[] { "Not Repeating", "Daily (Business Days)", "Weekly", "Bi-Weekly", "Monthly", "Yearly" } }; if (id != null) { student student = db.students.Single(s => s.studentid == id); model.Attendees = student.fname + " " + student.lname + " (" + student.studentid + "), "; } return View(model); }