public ActionResult Confirmation(string Code) { int studentID = new Student(Code, Musical.CurrentMusical().musicalID).studentID; StudentConfirmationModel m = new StudentConfirmationModel(); m.ConfirmationMessage = Musical.CurrentMusical().confirmationMessage; m.Code = Code; StudentTime st = new StudentTime(studentID, Musical.CurrentMusical().musicalID); DateTime myDate = st.Date(); string dateSuffix = (myDate.Day % 10 == 1 && myDate.Day != 11) ? "st" : (myDate.Day % 10 == 2 && myDate.Day != 12) ? "nd" : (myDate.Day % 10 == 3 && myDate.Day != 13) ? "rd" : "th"; m.AuditionDate = st.Date().ToString("dddd, MMMM d") + dateSuffix; m.AuditionGroup = st.TimeName(); return View(m); }
public ActionResult SaveStudent(AdminEditstudentViewModel m) { Student myStudent = new Student(); try { if (ModelState.IsValid) { myStudent.code = m.Code; myStudent.firstName = m.FirstName; myStudent.lastName = m.LastName; myStudent.email = m.Email; myStudent.grade = m.Grade; myStudent.gender = m.Gender; myStudent.musicalID = m.MusicalID; myStudent.studentID = m.StudentID; List<int> DesiredRoles = new List<int>(); DesiredRoles.Add(m.RoleID); myStudent.Save(DesiredRoles); StudentTime st = new StudentTime(); st.studentID = myStudent.studentID; st.timeID = m.TimeID; if (!st.IsAvailable()) throw new Exception("Too slow! This time has filled up. Please select another time."); st.Save(); } else { m.RoleList = MusicalRole.AllRoles(m.MusicalID).Select(r => new SelectListItem() { Text = r.name, Value = r.roleID.ToString() }); m.DateList = AuditionDate.MusicalDates(m.MusicalID).Select(r => new SelectListItem() { Text = ((DateTime)r.date).ToString("MM/dd/yyyy"), Value = r.dateID.ToString() }); if (m.DateID == 0) m.DateID = m.DateList.Select(r => Int32.Parse(r.Value)).FirstOrDefault(); m.TimeList = AuditionTime.TimeSlots(m.DateID).Select(t => new SelectListItem() { Text = t.timeDescription, Value = t.timeID.ToString() }); return View("EditStudent", m); } } catch (Exception ex) { m.RoleList = MusicalRole.AllRoles(m.MusicalID).Select(r => new SelectListItem() { Text = r.name, Value = r.roleID.ToString() }); m.DateList = AuditionDate.MusicalDates(m.MusicalID).Select(r => new SelectListItem() { Text = ((DateTime)r.date).ToString("MM/dd/yyyy"), Value = r.dateID.ToString() }); if (m.DateID == 0) m.DateID = m.DateList.Select(r => Int32.Parse(r.Value)).FirstOrDefault(); m.TimeList = AuditionTime.TimeSlots(m.DateID).Select(t => new SelectListItem() { Text = t.timeDescription, Value = t.timeID.ToString() }); ModelState.AddModelError("", ex.Message); return View("EditStudent", m); } return RedirectToRoute("AdminStudents", new { musicalID = myStudent.musicalID }); }
public StudentMyTimeModel(string code) { this.Code = code; this.MusicalDates = new List<MusicalDate>(); int thisMusicalID = Musical.CurrentMusical().musicalID; int studentID = new Student(code, thisMusicalID).studentID; StudentTime existingTime = new StudentTime(studentID, thisMusicalID); if (existingTime.timeID != 0) { DateTime myDate = existingTime.Date(); string dateSuffix = (myDate.Day % 10 == 1 && myDate.Day != 11) ? "st" : (myDate.Day % 10 == 2 && myDate.Day != 12) ? "nd" : (myDate.Day % 10 == 3 && myDate.Day != 13) ? "rd" : "th"; string AuditionDate = existingTime.Date().ToString("dddd, MMMM d") + dateSuffix; string AuditionGroup = existingTime.TimeName(); this.HasTime = true; this.InfoMessage = "You have already signed up for <strong>" + AuditionGroup + "</strong> on <strong>" + AuditionDate + "</strong>. Click \"Sign Up\" on another time to change your audition group."; } else { this.HasTime = false; } foreach (MusicalDate md in MusicalDate.AllDates(thisMusicalID)) { foreach (TimeSlot ts in md.TimeSlots) { if (ts.ID == existingTime.timeID) { ts.Status = "Mine"; } } this.MusicalDates.Add(md); } }
public ActionResult SubmitMyTime(string Code, string timeID) { StudentMyTimeModel m = new StudentMyTimeModel(Code); try { if (ModelState.IsValid) { StudentTime st = new StudentTime(); st.studentID = new Student(Code, Musical.CurrentMusical().musicalID).studentID; st.timeID = Int32.Parse(timeID); if (!st.IsAvailable()) throw new Exception("Too slow! This time has filled up. Please select another time."); st.Save(); return RedirectToRoute("StudentConfirmation", new { Code = Code }); } else { return View("MyTime", m); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return View("MyTime", m); } }