public ActionResult AdvisorIssueReport(AdvisorReportModel model) { try { employee employee = db.employees.Single(emp => emp.employeeid == User.Identity.Name); IEnumerable<employee> employees = db.employees.Where(emp => emp.role == "Student Advisor"); 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 }; EmployeeID.Add(poco); } model.Employee = model.EmpID.Remove(0, model.EmpID.Length - 10); model.Employee = model.Employee.Remove(model.Employee.Length - 1); model.EmployeeID = EmployeeID; model.User = employee.fname + " " + employee.lname + " (" + employee.employeeid + ")"; return View(model); } catch (Exception ex) { return View(model); } }
// // GET: /Reports/StudentIssueReport public ActionResult AdvisorIssueReport() { try { employee employee = db.employees.Single(emp => emp.employeeid == User.Identity.Name); IEnumerable<employee> employees = db.employees.Where(emp => emp.role == "Student Advisor"); 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 }; EmployeeID.Add(poco); } AdvisorReportModel model = new AdvisorReportModel() { EmpID = employee.fname + " " + employee.lname + " (" + employee.employeeid + ")", Employee = employee.employeeid, EmployeeID = EmployeeID, startDate = db.issues.OrderBy(i => i.date).First().date, endDate = db.issues.OrderByDescending(i => i.date).First().date, User = employee.fname + " " + employee.lname + " (" + employee.employeeid + ")" }; return View(model); } catch (Exception ex) { return View(); } }
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); }
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> /// 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); }
public ActionResult Index(IndexCalendarModel model) { IEnumerable<appointment> appoint; List<appointment> appointments; if (model.cName.Equals("All")) { if (User.IsInRole("Receptionist")) { appoint = db.appointments; } else { appoint = db.appointments.Where(i => i.employeeid == User.Identity.Name); } } else { if (User.IsInRole("Receptionist")) { appoint = db.appointments.Where(i => i.cname == model.cName); } else { appoint = db.appointments.Where(i => i.employeeid == User.Identity.Name && i.cname == model.cName); } } if (model.advisorID != null) { model.advisorID = model.advisorID.Remove(0, model.advisorID.Length - 10); model.advisorID = model.advisorID.Remove(model.advisorID.Length - 1); appoint = appoint.Where(a => a.employeeid == model.advisorID); appointments = appoint.ToList(); IEnumerable<Attendee> Attendee = db.Attendees.Where(i => i.attendee1 == model.advisorID && (i.confirmed == true || i.confirmed == null)); foreach (Attendee Attend in Attendee) { if (model.cName.Equals("All")) { appointments.Add(db.appointments.Single(i => i.appointmentid == Attend.appointmentid)); } else { appointment app = db.appointments.Single(i => i.appointmentid == Attend.appointmentid); if (app.cname == model.cName) appointments.Add(app); } } } else { appointments = appoint.ToList(); } if (!User.IsInRole("Receptionist")) { IEnumerable<Attendee> Attendee = db.Attendees.Where(i => i.attendee1 == User.Identity.Name && (i.confirmed == true || i.confirmed == null)); foreach (Attendee Attend in Attendee) { if (model.cName.Equals("All")) { appointments.Add(db.appointments.Single(i => i.appointmentid == Attend.appointmentid)); } else { appointment app = db.appointments.Single(i => i.appointmentid == Attend.appointmentid); if (app.cname == model.cName) appointments.Add(app); } } } List<Events> events = new List<Events>(); foreach (appointment appointment in appointments) { Events Events = new Events(); Events.id = appointment.appointmentid; Events.title = appointment.subject; Events.allDay = appointment.allday; Events.start = ConvertToUnixTimestamp(appointment.starttime).ToString(); Events.end = ConvertToUnixTimestamp(appointment.endtime).ToString(); Events.url = Url.Action("Details/" + appointment.appointmentid.ToString()); switch (appointment.appointmenttype.Trim()) { case "Personal": Events.color = "#009B00"; break; case "Advisement": Events.color = "#36C"; break; case "Office": Events.color = "#800080"; break; } events.Add(Events); } IEnumerable<campu> campus = db.campus; List<String> list = new List<String>(); list.Add("All"); foreach (campu camp in campus) { list.Add(camp.cname); } 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 }; EmployeeID.Add(poco); } model.cNames = list; model.Events = events; model.AutoCom = EmployeeID; return View(model); }
public ActionResult StudentIssueReport(StudentReportModel model) { try { employee employee = db.employees.Single(emp => emp.employeeid == User.Identity.Name); IEnumerable<student> students = db.students; List<AutoCompletePOCO> StudentID = 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" }; StudentID.Add(poco); } model.Student = model.StudentID.Remove(0, model.StudentID.Length - 10); model.Student = model.Student.Remove(model.Student.Length - 1); model.StudID = StudentID; model.User = employee.fname + " " + employee.lname + " (" + employee.employeeid + ")"; return View(model); } catch (Exception ex) { return View(model); } }
// // GET: /Reports/StudentIssueReport public ActionResult StudentIssueReport() { try { employee employee = db.employees.Single(emp => emp.employeeid == User.Identity.Name); IEnumerable<student> students = db.students; List<AutoCompletePOCO> StudentID = 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" }; StudentID.Add(poco); } StudentReportModel model = new StudentReportModel() { StudentID = "", Student = "", StartDate = db.issues.OrderBy(i => i.date).First().date, EndDate = db.issues.OrderByDescending(i => i.date).First().date, StudID = StudentID, User = employee.fname + " " + employee.lname + " (" + employee.employeeid + ")" }; return View(model); } catch (Exception ex) { return View(); } }