public ActionResult DeleteEvent(int id) { EventDBEntities _db = new EventDBEntities(); var Model = _db.Events.Where(e => e.EventID == id).FirstOrDefault(); //Set admin id here SendEmail("*****@*****.**", Model.EventTitle + " Deleted", "Your event has been deleted"); Models.Event myEvent = (Models.Event)_db.Events.Where(y => y.EventID == id).FirstOrDefault(); if (myEvent.EventDate >= DateTime.Today && myEvent.Volunteers != null) { var volunteers = myEvent.Volunteers.ToList(); foreach (var volunteer in volunteers) { AdminUnScheduleVolunteer((int)volunteer.ID, id); } } //have to do this AFTER emailing volunteers EventSPEntities x = new EventSPEntities(); x.Delete_Event(id); return(new EmptyResult()); }
public ActionResult UpdateEvent(int id, string title, string description, string date, string start, string end, string maxVolunteers) { try { DateTime myDate = DateTime.Parse(date); TimeSpan myStart = TimeSpan.Parse(start); TimeSpan myEnd = TimeSpan.Parse(end); int numVolunteers = Int32.Parse(maxVolunteers); if (NameValidation(title) && DescriptionValidation(description)) { EventSPEntities x = new EventSPEntities(); x.Update_Event(id, title, description, myDate, myStart, myEnd, numVolunteers); } else { return(Json(new { status = "error", message = "invalid information entered" })); } } catch { return(Json(new { status = "error", message = "invalid information entered" })); } return(new EmptyResult()); }
public ActionResult AddEvent(string title, string description, string date, string start, string end, string maxVolunteers) { if (true) { try { DateTime myDate = DateTime.Parse(date); TimeSpan myStart = TimeSpan.Parse(start); TimeSpan myEnd = TimeSpan.Parse(end); int numVolunteers = Int32.Parse(maxVolunteers); if (NameValidation(title) && DescriptionValidation(description)) { EventSPEntities x = new EventSPEntities(); x.Insert_Event(title, description, myDate, myStart, myEnd, numVolunteers); } else { return(Json(new { status = "error", message = "Make sure Title is less than 20 characters and Description is less than 200 characters" })); } } catch { return(Json(new { status = "error", message = "invalid information entered" })); } } return(new EmptyResult()); }