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> /// Deletes Selected Event /// </summary> /// <param name="ID">Event ID</param> /// <returns>ActionResult</returns> public ActionResult Delete(int ID) { tblEvent existingEvent = _ODB.tblEvents.Where(e => e.ID == ID).SingleOrDefault(); if (existingEvent != null) { if (existingEvent.tblInvitations.Count > 0) { this.ShowPageError(string.Format("Event '{0}' could not be deleted because it has existing student invitations.", existingEvent.Name)); } else if (existingEvent.tblEventDates.Count > 0) { this.ShowPageError(string.Format("Event '{0}' could not be deleted because it has existing event dates.", existingEvent.Name)); } else { string eventName = existingEvent.Name; _ODB.DeleteObject(existingEvent); _ODB.SaveChanges(); this.ShowPageMessage(string.Format("Event '{0}' was successfully deleted.", eventName)); SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, String.Format("User {0} deleted event with ID {1}.", Current.User.Username, ID)); } } else { this.ShowPageError(string.Format("An event could not be found for the given ID. Nothing was deleted.", ID)); } return(this.RedirectToAction <EventsController>(c => c.Index())); }
//methods public void Insert() { try { LFGuestSystemEntities oDc = new LFGuestSystemEntities(); tblEvent t_event = new tblEvent(); t_event.EventID = 1; // automatically calculate the new tblEventID if (oDc.tblEvents.Count() > 0) { t_event.EventID = oDc.tblEvents.Max(p => p.EventID) + 1; } // fill in the data this.EventID = t_event.EventID; t_event.Date = this.Date; t_event.MealCount = 0; t_event.VolunteerCount = 0; t_event.SiteID = this.SiteID; t_event.WeatherDesc = "Clear"; t_event.Temp = 50.0m; t_event.ChildTray = 0; t_event.AdultTray = 0; t_event.IsActive = true; t_event.Comments = this.Comments; oDc.tblEvents.Add(t_event); oDc.SaveChanges(); } catch (Exception ex) { throw ex; } }
public bool Insert() { try { using (ITIndeedEntities dc = new ITIndeedEntities()) { tblEvent tevent = new tblEvent(); tevent.Id = Guid.NewGuid(); tevent.Name = this.Name; tevent.Type = this.Type; tevent.StartDate = Convert.ToDateTime(this.StartDate); tevent.EndDate = Convert.ToDateTime(this.EndDate); //the error was the same thing as above all good now :) dc.tblEvents.Add(tevent); dc.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }
public bool LoadById(Guid id) { try { using (ITIndeedEntities dc = new ITIndeedEntities()) { tblEvent tevent = dc.tblEvents.Where(e => e.Id == id).FirstOrDefault(); if (tevent != null) { this.Id = tevent.Id; this.Name = tevent.Name; this.Type = tevent.Type; this.StartDate = tevent.StartDate; this.EndDate = tevent.EndDate; //Gage - Error Came from trying to pull a UserId from the Event Table, the user ID is part of the tblEventShowing Junction table -- i.e. A user can have many events and an event can have many users // otherwise looks good return(true); } else { return(false); } } } catch (Exception ex) { throw ex; } }
public IHttpActionResult InsertOEvent(OEvent oevent) { PenOCDataContext db = new PenOCDataContext(); tblEvent eventRecord = new tblEvent { strName = oevent.name, strControllerReport = oevent.controllerReport, intVenue = oevent.venueId, strCourses = oevent.courses, dteDate = oevent.date, strDirections = oevent.directions, intPlanner = oevent.plannerId, intController = oevent.controllerId, strRegTime = oevent.registrationTime, strStarts = oevent.startTime, strClose = oevent.close, strSpecialNote = oevent.specialNote, decCoordinateLat = oevent.coordinateLatitude, decCoordinateLong = oevent.coordinateLongitude, strCost = oevent.cost, intMaxPoints = oevent.maxPoints, strPlannerReport = oevent.plannerReport, intOrganisingClub = oevent.organizingClubId }; db.tblEvents.InsertOnSubmit(eventRecord); db.SubmitChanges(); oevent.id = eventRecord.idEvent; return Ok(oevent); }
public ActionResult DeleteConfirmed(int id) { tblEvent tblEvent = db.tblEvents.Find(id); db.tblEvents.Remove(tblEvent); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "EventName, Date, TypeOfEventID, Location, Latitude, Longitude")] tblEvent tblEvent) { using (Service1Client wcf = new Service1Client()) { wcf.AddEvent(tblEvent); } return(RedirectToAction("Index", "Event1")); }
public ActionResult Edit([Bind(Include = "eventID,eventDesc")] tblEvent tblEvent) { if (ModelState.IsValid) { db.Entry(tblEvent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblEvent)); }
public ActionResult Create([Bind(Include = "eventID,eventDesc")] tblEvent tblEvent) { if (ModelState.IsValid) { db.tblEvents.Add(tblEvent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblEvent)); }
public ActionResult Create([Bind(Include = "intEventID,strEventTitle,strEventDetails,dtmDate")] tblEvent tblEvent) { if (ModelState.IsValid) { db.tblEvents.Add(tblEvent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblEvent)); }
public ActionResult Edit([Bind(Include = "EventID, EventName, Date, TypeOfEventID, Location, Latitude, Longitude")] tblEvent tblevent) { if (ModelState.IsValid) { using (Service1Client wcf = new Service1Client()) { wcf.AddEvent(tblevent); } return(RedirectToAction("Index", "Event1")); } return(View(tblevent)); }
// GET: Events/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblEvent tblEvent = db.tblEvents.Find(id); if (tblEvent == null) { return(HttpNotFound()); } return(View(tblEvent)); }
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 Details /// </summary> /// <param name="ID">Event ID</param> /// <returns>ActionResult</returns> public ActionResult Event(int ID) { tblEvent Event = _ODB.tblEvents.Where(e => e.ID == ID).SingleOrDefault(); EventViewModel Model = new EventViewModel(); if (Event != null) { Model = new EventViewModel(Event); } else { this.ShowPageError(string.Format("An event could not be found for the given ID {0}", ID)); } return(View(Model)); }
/// <summary> /// List of Invitations for the given Event /// </summary> /// <param name="ID">Event ID</param> /// <returns>ActionResult</returns> public ActionResult Invitations(int ID) { tblEvent Event = _ODB.tblEvents.Where(e => e.ID == ID).SingleOrDefault(); List <tblInvitation> Model = new List <tblInvitation>(); if (Event != null) { Model = Event.tblInvitations.ToList(); ViewBag.Event = Event; } else { this.ShowPageError(String.Format("An Event could not be found for the given ID: {0}", ID)); } return(View(Model)); }
public ActionResult ResendInvitationEmail(int ID) { tblEvent Event = _ODB.tblEvents.Where(e => e.ID == ID).SingleOrDefault(); if (Event != null) { SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, string.Format("User {0} is resending invitation emails for Event '{1}'", Current.User.Username, Event.Name)); Classes.Notifications.EventInvitation(Event, Event.tblInvitations.ToList()); this.ShowPageMessage(string.Format("Notifications have been processed for Event: '{0}'. The '{1}' email account will be notified once done.", Event.Name, Settings.DefaultEmailTo)); } else { this.ShowPageError(string.Format("An event could not be found for the given ID {0}", ID)); } return(this.RedirectToAction <EventsController>(c => c.Event(ID))); }
public string ToggleEventStatus(int ID) { string retVal = string.Empty; tblEvent Event = _ODB.tblEvents.Where(e => e.ID == ID).SingleOrDefault(); if (Event != null) { Event.IsEnabled = !Event.IsEnabled; _ODB.SaveChanges(); retVal = String.Format("Event '{0}' was successfully {1}", Event.Name, Event.IsEnabled ? "Enabled" : "Disabled"); SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, String.Format("User {0} updated status for event with ID {1}.", Current.User.Username, ID)); } else { retVal = String.Format("Could not find an event for the given ID {0}", ID); } return(retVal); }
public ActionResult Create(EventViewModel Model) { tblEvent Event = new tblEvent(); if (ModelState.IsValid) { Event = Model.As_tblEvent(); _ODB.tblEvents.AddObject(Event); _ODB.SaveChanges(); this.ShowPageMessage(String.Format("The event '{0}' was created successfully.", Event.Name)); } else { this.ShowPageError(DataConstants.ModelStateInvalidError); return(View("Index", Model)); } SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, String.Format("User {0} created an event with ID {1}; Name: '{2}.'", Current.User.Username, Event.ID, Event.Name)); return(this.RedirectToAction <EventsController>(c => c.Event(Event.ID))); }
public object AddEvent(string EventName, int EventTypeID, string Venue, string StartTime, string EndTime, string Subject, string Description, int Priority, int CreatedBy) { var DC = new DataClassesDataContext(); tblEvent EventObj = new tblEvent(); EventObj.EventName = EventName; EventObj.EventTypeID = EventTypeID; EventObj.Venue = Venue; EventObj.StartTime = Convert.ToDateTime(StartTime); EventObj.EndTime = Convert.ToDateTime(EndTime); EventObj.Subject = Subject; EventObj.Description = Description; EventObj.Priority = Convert.ToByte(Priority); EventObj.CreatedBy = CreatedBy; EventObj.IsActive = true; DC.tblEvents.InsertOnSubmit(EventObj); DC.SubmitChanges(); return(true); }
public int GetEventID(DateTime date, int site) { this.Date = date; this.SiteID = site; try { LFGuestSystemEntities oDc = new LFGuestSystemEntities(); tblEvent t_event = oDc.tblEvents.Where(p => (p.Date == this.Date && p.SiteID == this.SiteID)).FirstOrDefault(); if (t_event == null) { Insert(); } return(this.EventID); } catch (Exception ex) { throw ex; } }
public object EditEvent(int EventID, string EventName, int EventTypeID, string Venue, string StartTime, string EndTime, string Subject, string Description, int Priority, int CreatedBy, bool IsActive) { var DC = new DataClassesDataContext(); tblEvent EventObj = (from ob in DC.tblEvents where ob.EventID == EventID select ob).Single(); EventObj.EventName = EventName; EventObj.EventTypeID = EventTypeID; EventObj.Venue = Venue; EventObj.StartTime = Convert.ToDateTime(StartTime); EventObj.EndTime = Convert.ToDateTime(EndTime); EventObj.Subject = Subject; EventObj.Description = Description; EventObj.Priority = Convert.ToByte(Priority); EventObj.CreatedBy = CreatedBy; EventObj.IsActive = true; DC.SubmitChanges(); return(true); }
public ActionResult Save(EventViewModel Model) { tblEvent existingEvent = _ODB.tblEvents.Where(e => e.ID == Model.ID).SingleOrDefault(); if (existingEvent != null) { if (ModelState.IsValid) { existingEvent.EventTypeExclusion = Model.EventTypeExclusion; existingEvent.Description = Model.Description; existingEvent.EventTypeID = Model.EventTypeID; existingEvent.Fee = Model.Fee; existingEvent.ID = Model.ID; existingEvent.InvitationEmailID = Model.InvitationEmailID; existingEvent.IsEnabled = Model.IsEnabled; existingEvent.LaunchID = Model.LaunchID; existingEvent.Name = Model.Name; existingEvent.QuizID = Model.QuizID; existingEvent.Term = Model.Term; existingEvent.Blacklist = Model.Blacklist; existingEvent.Whitelist = Model.Whitelist; existingEvent.MarketplaceSite = Model.MarketplaceSite; _ODB.SaveChanges(); this.ShowPageMessage(String.Format("The event '{0}' was updated successfully.", existingEvent.Name)); SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, String.Format("User {0} updated Event {1}.", Current.User.Username, existingEvent.ID)); return(this.RedirectToAction <EventsController>(c => c.Event(existingEvent.ID))); } else { this.ShowPageError(DataConstants.ModelStateInvalidError); return(View("Event", Model)); } } else { this.ShowPageError("An event could not be found for the given Event ID."); return(this.RedirectToAction <EventsController>(c => c.Index())); } }
public void Update() { try { using (ITIndeedEntities dc = new ITIndeedEntities()) { tblEvent tevent = dc.tblEvents.Where(e => e.Id == this.Id).FirstOrDefault(); if (tevent != null) { tevent.Name = this.Name; tevent.Type = this.Type; tevent.StartDate = this.StartDate; tevent.EndDate = this.EndDate; dc.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public void Delete() { try { using (ITIndeedEntities dc = new ITIndeedEntities()) { tblEvent tevent = dc.tblEvents.Where(e => e.Id == this.Id).FirstOrDefault(); if (tevent != null) { var eventShowings = dc.tblEventShowings.Where(e => e.EventId == this.Id); dc.tblEventShowings.RemoveRange(eventShowings); dc.tblEvents.Remove(tevent); dc.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
// state that the method you intend to create is a POST public HttpResponseMessage ussd([FromBody] Models.ServerResponse ServerResponse) { // declare a complex type as input parameter HttpResponseMessage rs; string response; string eventType = string.Empty; if (ServerResponse.text == null) { ServerResponse.text = ""; } // loop through the server's text value to determine the next cause of action if (ServerResponse.text.Equals("", StringComparison.Ordinal)) { NewsManagementDBEntities entity = new NewsManagementDBEntities(); tblRequest tableRequest = new USSD_Application.tblRequest(); tableRequest.PhoneNumber = ServerResponse.phoneNumber; tableRequest.ServiceCode = ServerResponse.serviceCode; tableRequest.SessionID = ServerResponse.sessionId; tableRequest.RequestStartDateTime = DateTime.Now; entity.tblRequests.Add(tableRequest); entity.SaveChanges(); response = "CON Welcome to our service \n"; response += " What type of NEWS you want today \n"; response += " 1. Sport \n"; response += " 2. Music \n"; response += " 3. Movie \n"; } else { string[] request = ServerResponse.text.Split('*'); if (request.Count() == 1) { response = "CON Please Enter Date to filter \n"; } else if (request.Count() == 2) { eventType = GetEventType(request[0]); DateTime eventDate = DateTime.Parse(request[1]); NewsManagementDBEntities entity = new NewsManagementDBEntities(); List <tblEvent> events = entity.tblEvents.Where(x => x.EventType == eventType && x.CreatedDate == eventDate).ToList(); if (events != null && events.Count > 0) { string newsTitles = string.Empty; response = "CON Please Enter the CODE on the left \n"; foreach (tblEvent singleEvent in events) { response += singleEvent.ID + ". " + singleEvent.Title + " \n"; } } else { response = "END Invalid Code selected"; } } else if (request.Count() == 3) { eventType = GetEventType(request[0]); DateTime eventDate = DateTime.Parse(request[1]); int eventID = int.Parse(request[2]); NewsManagementDBEntities entity = new NewsManagementDBEntities(); tblEvent singleEvent = entity.tblEvents.Where(x => x.ID == eventID && x.EventType == eventType && x.CreatedDate == eventDate).FirstOrDefault(); if (singleEvent != null) { response = "END " + singleEvent.Description; tblRequest oldRequest = entity.tblRequests.Where(x => x.SessionID == ServerResponse.sessionId).FirstOrDefault(); tblRequest newRequest = new tblRequest(); newRequest.PhoneNumber = ServerResponse.phoneNumber; newRequest.ServiceCode = ServerResponse.serviceCode; newRequest.SessionID = ServerResponse.sessionId; newRequest.RequestStartDateTime = oldRequest.RequestStartDateTime; newRequest.RequestCompleteDateTime = DateTime.Now; entity.Entry(oldRequest).CurrentValues.SetValues(newRequest); entity.SaveChanges(); } else { response = "END Invalid Code selected"; } } else { response = "END Invalid Option"; } } rs = Request.CreateResponse(HttpStatusCode.Created, response); rs.Content = new StringContent(response, Encoding.UTF8, "text/plain"); return(rs); }
public Response SaveEventMasterDetails(EventMasterCustomModel objModel) { using (response = new Response()) { using (dbcontext = new SchoolManagementEntities()) { try { response.success = true; if (objModel.EventId == 0) { var rs = dbcontext.tblEvents.FirstOrDefault(x => x.IsDeleted == false && x.Title == objModel.Title); if (rs == null) { tblEvent objAddNew = new tblEvent { SchoolId = Convert.ToInt32(CommonHelper.TaskSchoolId.SchoolId), Title = objModel.Title, ShortDescription = objModel.ShortDescription, DDate = DateTime.Now, StartDate = objModel.StartDate, EndDate = objModel.EndDate, Image = objModel.Image, IsActive = true, IsDeleted = false, CreatedBy = objModel.CreatedBy, CreatedDate = DateTime.Now, ModifiedBy = objModel.ModifiedBy, ModifiedDate = DateTime.Now }; dbcontext.tblEvents.Add(objAddNew); dbcontext.SaveChanges(); response.responseData = new { EventId = objAddNew.EventId, Title = objAddNew.Title }; response.message = "Record Added Successfully!"; } else { response.success = false; response.message = "Record Already Exists!"; } } else { var rs = dbcontext.tblEvents.FirstOrDefault(x => x.IsDeleted == false && x.Title == objModel.Title && x.EventId != objModel.EventId); if (rs == null) { var objUpdate = dbcontext.tblEvents.FirstOrDefault(m => m.EventId == objModel.EventId); if (objUpdate != null) { objUpdate.Title = objModel.Title; objUpdate.ShortDescription = objModel.ShortDescription; objUpdate.DDate = DateTime.Now; objUpdate.StartDate = objModel.StartDate; objUpdate.EndDate = objModel.EndDate; objUpdate.Image = objModel.Image; objUpdate.ModifiedBy = objModel.ModifiedBy; objUpdate.ModifiedDate = DateTime.Now; dbcontext.SaveChanges(); response.responseData = new { EventId = objUpdate.EventId, Title = objUpdate.Title }; response.message = "Record Updated Successfully!"; } } else { response.success = false; response.message = "Record Already Exists!"; } } return(response); } catch (Exception ex) { response.success = false; response.message = ex.Message; return(response); } } } }