/// <summary> /// Deletes selected Event Date /// </summary> /// <param name="ID">Event Date ID</param> /// <returns>ActionResult</returns> public ActionResult DeleteEventDate(int ID) { tblEventDate existingEventDate = _ODB.tblEventDates.Where(e => e.ID == ID).SingleOrDefault(); if (existingEventDate != null) { if (existingEventDate.tblReservations.Count > 0) { this.ShowPageError(string.Format("Event Date '{0}' could not be deleted because it has existing student reservations.", existingEventDate.DateOfEvent.ToShortDateString())); } else { string eventDate = existingEventDate.DateOfEvent.ToShortDateString(); _ODB.DeleteObject(existingEventDate); _ODB.SaveChanges(); this.ShowPageMessage(string.Format("Event Date '{0}' was successfully deleted.", eventDate)); SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, String.Format("User {0} deleted event date with ID {1}.", Current.User.Username, ID)); } } else { this.ShowPageError(string.Format("An event date could not be found for the given ID. Nothing was deleted.", ID)); return(this.RedirectToAction <EventsController>(c => c.Index())); } return(this.RedirectToAction <EventsController>(c => c.Event(existingEventDate.EventID))); }
public ActionResult CreateEventDate(EventDateViewModel Model) { tblEventDate EventDate = new tblEventDate(); if (ModelState.IsValid) { EventDate = Model.As_tblEventDate(); _ODB.tblEventDates.AddObject(EventDate); _ODB.SaveChanges(); this.ShowPageMessage(String.Format("The event date for '{0}' was created successfully.", EventDate.DateOfEvent.ToShortDateString())); } else { this.ShowPageError(DataConstants.ModelStateInvalidError); tblEvent existingEvent = _ODB.tblEvents.Where(e => e.ID == Model.EventID).SingleOrDefault(); if (existingEvent != null) { return(View("Event", new EventViewModel(existingEvent))); } else { this.ShowPageError(DataConstants.ModelStateInvalidError + " Also, an event could not be found for the given Event ID."); return(this.RedirectToAction <EventsController>(c => c.Index())); } } SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, String.Format("User {0} created an event date with ID {1}; Date: '{2}.'", Current.User.Username, EventDate.ID, EventDate.DateOfEvent.ToShortDateString())); return(this.RedirectToAction <EventsController>(c => c.Event(EventDate.EventID))); }
/// <summary> /// Creates a Reservation given a student's invitation ID and the selected Event Date ID /// </summary> /// <param name="ID">Invitation ID</param> /// <param name="EventDateID">Event Date ID</param> /// <returns>ActionResult</returns> public ActionResult CreateReservation(int ID, int EventDateID) { tblInvitation Invitation = _ODB.tblInvitations.Where(e => e.ID == ID).SingleOrDefault(); tblEventDate EventDate = _ODB.tblEventDates.Where(e => e.ID == EventDateID).SingleOrDefault(); if (Invitation != null && EventDate != null) { if (Invitation.ENumber == Current.User.ENumber || Current.User.IsAdmin || Current.User.IsStaff) { tblReservation existingReservation = _ODB.tblReservations.Where(e => e.InvitationID == Invitation.ID).SingleOrDefault(); if (existingReservation == null) { if (EventDate.HasOpenSlots) { tblReservation Reservation = new tblReservation(); Reservation.tblEventDate = EventDate; Reservation.tblInvitation = Invitation; Reservation.IsCancelled = false; Reservation.IsConfirmed = false; _ODB.tblReservations.AddObject(Reservation); _ODB.SaveChanges(); Logging.Log(Logging.LogType.Audit, string.Format("User {0} created a Reservation with ID {1} for Invitation {2} for EventDate {3}", Current.User.Username, Reservation.ID, Invitation.ID, EventDate.ID)); this.ShowPageMessage("Your event reservation was successfully created!"); return(this.RedirectToAction <StudentController>(c => c.Reservation(Reservation.ID))); } else { this.ShowPageError(string.Format("The selected event date '{0}' no longer has an open slot for event '{1}'. Please select another event date.", existingReservation.tblEventDate.DateOfEvent.ToShortDateString(), existingReservation.tblEventDate.tblEvent.Name)); } } else { this.ShowPageError("A reservation already exists for the selected Invitation. Please update the reservation to change event dates."); } } else { this.ShowPageError("You are not authorized to view create reservations for this Invitation"); } } else { this.ShowPageError("Either the Invitation or the Event Date could not be retrieved given the specified IDs."); } if (Invitation != null) { return(this.RedirectToAction <StudentController>(c => c.Invitation(Invitation.ID))); } else { return(this.RedirectToAction <StudentController>(c => c.Index())); } }
/// <summary> /// Change the event date for a given reservation and new event id /// </summary> /// <param name="ID">Reservation ID</param> /// <param name="EventDateID">Event Date ID</param> /// <returns>ActionResult</returns> public ActionResult ChangeReservation(int ID, int EventDateID) { tblReservation Reservation = _ODB.tblReservations.Where(e => e.ID == ID).SingleOrDefault(); tblInvitation Invitation = Reservation != null ? Reservation.tblInvitation : null; tblEventDate EventDate = _ODB.tblEventDates.Where(e => e.ID == EventDateID).SingleOrDefault(); if (Invitation != null && EventDate != null) { if (Invitation.ENumber == Current.User.ENumber || Current.User.IsAdmin || Current.User.IsStaff) { if (Reservation != null) { if (EventDate.HasOpenSlots) { // delete unpaid guests to avoid conflicts with the number of allowed guests with different event dates, but yet preserve paid guests List <tblGuest> GuestsToDelete = Reservation.tblGuests.Where(e => !e.HasPaid).ToList(); GuestsToDelete.ForEach(e => _ODB.tblGuests.DeleteObject(e)); Reservation.tblEventDate = EventDate; _ODB.SaveChanges(); Logging.Log(Logging.LogType.Audit, string.Format("User {0} Changed the Event Date for Reservation with ID {1} for Invitation {2} for EventDate {3}", Current.User.Username, Reservation.ID, Invitation.ID, EventDate.ID)); this.ShowPageMessage("Your event date for your reservation was successfully changed!"); return(this.RedirectToAction <StudentController>(c => c.Reservation(Reservation.ID))); } else { this.ShowPageError(string.Format("The selected event date '{0}' no longer has an open slot for event '{1}'. Please select another event date.", Reservation.tblEventDate.DateOfEvent.ToShortDateString(), Reservation.tblEventDate.tblEvent.Name)); return(this.RedirectToAction <StudentController>(c => c.Reservation(Reservation.ID))); } } else { this.ShowPageError("A reservation could not be found by the given ID."); } } else { this.ShowPageError("You are not authorized to view create reservations for this Invitation"); } } else { this.ShowPageError("Either the Invitation or the Event Date could not be retrieved given the specified IDs."); } if (Invitation != null) { return(this.RedirectToAction <StudentController>(c => c.Invitation(Invitation.ID))); } else { return(this.RedirectToAction <StudentController>(c => c.Index())); } }
public ActionResult SaveEventDate(EventDateViewModel Model) { tblEventDate existingEventDate = _ODB.tblEventDates.Where(e => e.ID == Model.ID).SingleOrDefault(); if (existingEventDate != null) { if (ModelState.IsValid) { existingEventDate.ConfirmationEmailID = Model.ConfirmationEmailID; existingEventDate.ReminderEmailID = Model.ReminderEmailID; existingEventDate.DateOfEvent = Model.DateOfEvent; existingEventDate.EventDateType = Model.EventDateType; existingEventDate.EventID = Model.EventID; existingEventDate.ID = Model.ID; existingEventDate.IsEnabled = Model.IsEnabled; existingEventDate.MaxNumberOfStudents = Model.MaxNumberOfStudents; existingEventDate.AutomaticallyClearSOHolds = Model.AutomaticallyClearSOHolds; existingEventDate.Description = Model.Description; existingEventDate.AllowGuestRegistration = Model.AllowGuestRegistration; existingEventDate.MaxNumberGuests = Model.MaxNumberGuests; existingEventDate.CostPerGuest = Model.CostPerGuest; existingEventDate.UpdateSGBSTDN_ORSN = Model.UpdateORSN; existingEventDate.HideEventDate = Model.HideEventDate; _ODB.SaveChanges(); this.ShowPageMessage(String.Format("Event Date '{0}' was updated successfully.", existingEventDate.DateOfEvent.ToShortDateString())); SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, String.Format("User {0} updated Event Date {1}.", Current.User.Username, existingEventDate.ID)); return(this.RedirectToAction <EventsController>(c => c.Event(existingEventDate.EventID))); } else { tblEvent existingEvent = _ODB.tblEvents.Where(e => e.ID == Model.EventID).SingleOrDefault(); if (existingEvent != null) { return(View("Event", new EventViewModel(existingEvent))); } else { this.ShowPageError(DataConstants.ModelStateInvalidError + " Also, an event could not be found for the given Event ID."); return(this.RedirectToAction <EventsController>(c => c.Index())); } } } else { this.ShowPageError("An event could not be found for the given Event ID."); return(this.RedirectToAction <EventsController>(c => c.Index())); } }
/// <summary> /// Displays Event Date Details /// </summary> /// <param name="ID">Event Date ID</param> /// <returns>ActionResult</returns> public ActionResult EventDate(int ID) { tblEventDate EventDate = _ODB.tblEventDates.Where(e => e.ID == ID).SingleOrDefault(); EventDateViewModel Model = new EventDateViewModel(); if (EventDate != null) { Model = new EventDateViewModel(EventDate); } else { this.ShowPageError(string.Format("An event date could not be found for the given ID {0}", ID)); } return(View(Model)); }
/// <summary> /// Sends Event Date Reminder for the selected Event Date /// </summary> /// <param name="ID">Event Date ID</param> /// <returns>ActionResult</returns> public ActionResult EventDateReminder(int ID) { tblEventDate EventDate = _ODB.tblEventDates.Where(e => e.ID == ID).SingleOrDefault(); EventDateViewModel Model = new EventDateViewModel(); if (EventDate != null) { Notifications.EventDateReminder(EventDate); this.ShowPageMessage(string.Format("Sending reminder for Event Date: '{0}' taking place on {1} to confirmed reservations.", EventDate.Description, EventDate.DateOfEvent.ToShortDateString())); return(this.RedirectToAction <EventsController>(c => c.Event(EventDate.EventID))); } else { this.ShowPageError(string.Format("An event date could not be found for the given ID {0}", ID)); } return(this.RedirectToAction <EventsController>(c => c.Index())); }
public string ToggleEventDateStatus(int ID) { string retVal = string.Empty; tblEventDate EventDate = _ODB.tblEventDates.Where(e => e.ID == ID).SingleOrDefault(); if (EventDate != null) { EventDate.IsEnabled = !EventDate.IsEnabled; _ODB.SaveChanges(); retVal = String.Format("Event Date '{0}' was successfully {1}", EventDate.DateOfEvent.ToShortDateString(), EventDate.IsEnabled ? "Enabled" : "Disabled"); SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, String.Format("User {0} updated status for event date with ID {1}.", Current.User.Username, ID)); } else { retVal = String.Format("Could not find an event date for the given ID {0}", ID); } return(retVal); }