/// <summary> /// Gets the edit value as the IEntity.Id /// </summary> /// <param name="control">The control.</param> /// <param name="configurationValues">The configuration values.</param> /// <returns></returns> public int?GetEditValueAsEntityId(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues) { Guid guid = GetEditValue(control, configurationValues).AsGuid(); var item = EventCalendarCache.Get(guid); return(item != null ? item.Id : (int?)null); }
/// <summary> /// Bulks the index documents by calendar. /// </summary> /// <param name="calendarId">The calendar identifier.</param> public void BulkIndexDocumentsByCalendar(int calendarId) { // Ensure provided calendar is indexable var calendar = EventCalendarCache.Get(calendarId); if (calendar == null || !calendar.IsIndexEnabled) { return; } var eventItems = new EventItemService(new RockContext()) .GetActiveItemsByCalendarId(calendarId) .Select(a => a.Id).ToList(); int eventItemEntityTypeId = EntityTypeCache.GetId <Rock.Model.EventItem>().Value; foreach (var eventItemId in eventItems) { var deleteEntityTypeIndexMsg = new DeleteEntityTypeIndex.Message { EntityTypeId = eventItemEntityTypeId, EntityId = eventItemId }; deleteEntityTypeIndexMsg.Send(); } }
/// <summary> /// Loads the Event Calendar /// </summary> private EventCalendarCache GetEventCalendar() { // Get the event calendar id (initial page request) if (!EventCalendarId.HasValue) { // Get event calendar set by attribute value Guid eventCalendarGuid = GetAttributeValue(AttributeKey.EventCalendar).AsGuid(); EventCalendarCache _eventCalendarCache = null; if (!eventCalendarGuid.IsEmpty()) { _eventCalendarCache = EventCalendarCache.Get(eventCalendarGuid); } // If an attribute value was not provided, check for query/route value if (_eventCalendarCache != null) { EventCalendarId = _eventCalendarCache.Id; } else { EventCalendarId = PageParameter(PageParameterKey.EventCalendarId).AsIntegerOrNull(); } } // Get the workflow type if (EventCalendarId.HasValue) { return(EventCalendarCache.Get(EventCalendarId.Value)); } else { return(null); } }
/// <summary> /// Deletes the indexed documents by calendar. /// </summary> /// <param name="calendarId">The calendar identifier.</param> public void DeleteIndexedDocumentsByCalendarId(int calendarId) { // Ensure provided calendar is indexable var calendar = EventCalendarCache.Get(calendarId); if (calendar == null || !calendar.IsIndexEnabled) { return; } // Get event items for this calendar that are ONLY on this calendar. // We don't want to delete items that are also on another calendar. var eventItems = new EventItemService(new RockContext()) .GetActiveItemsByCalendarId(calendarId) .Where(i => i.EventCalendarItems.Count() == 1) .Select(a => a.Id).ToList(); int eventItemEntityTypeId = EntityTypeCache.GetId <Rock.Model.EventItem>().Value; foreach (var eventItemId in eventItems) { var deleteEntityTypeIndexMsg = new DeleteEntityTypeIndex.Message { EntityTypeId = eventItemEntityTypeId, EntityId = eventItemId }; deleteEntityTypeIndexMsg.Send(); } }
/// <summary> /// Sets the edit value from IEntity.Id value /// </summary> /// <param name="control">The control.</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="id">The identifier.</param> public void SetEditValueFromEntityId(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, int?id) { EventCalendarCache item = null; if (id.HasValue) { item = EventCalendarCache.Get(id.Value); } string guidValue = item != null?item.Guid.ToString() : string.Empty; SetEditValue(control, configurationValues, guidValue); }
/// <summary> /// Sets the value. /// Expects value as a EventCalendar.Guid as string /// </summary> /// <param name="control">The control.</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="value">The value.</param> public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value) { EventCalendarPicker eventCalendarPicker = control as EventCalendarPicker; if (eventCalendarPicker != null) { Guid guid = value.AsGuid(); // get the item (or null) and set it var eventCalendar = EventCalendarCache.Get(guid); eventCalendarPicker.SetValue(eventCalendar == null ? "0" : eventCalendar.Id.ToString()); } }
/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override System.Web.UI.Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { var eventCalendarPicker = new EventCalendarPicker { ID = id }; if (EventCalendarCache.All().Any()) { return(eventCalendarPicker); } return(null); }
/// <summary> /// Returns the field's current value(s) /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="value">Information about the value</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param> /// <returns></returns> public override string FormatValue(System.Web.UI.Control parentControl, string value, Dictionary <string, ConfigurationValue> configurationValues, bool condensed) { string formattedValue = value; if (!string.IsNullOrWhiteSpace(value)) { var eventCalendar = EventCalendarCache.Get(value.AsGuid()); if (eventCalendar != null) { formattedValue = eventCalendar.Name; } } return(base.FormatValue(parentControl, formattedValue, configurationValues, condensed)); }
/// <summary> /// Returns the field's current value(s) /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="value">Information about the value</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param> /// <returns></returns> public override string FormatValue(System.Web.UI.Control parentControl, string value, Dictionary <string, ConfigurationValue> configurationValues, bool condensed) { string formattedValue = value; if (!string.IsNullOrWhiteSpace(value)) { var guids = value.SplitDelimitedValues(); var eventCalendars = guids.Select(g => EventCalendarCache.Get(g)); if (eventCalendars.Any()) { formattedValue = string.Join(", ", (from eventCalendar in eventCalendars select eventCalendar.Name).ToArray()); } } return(base.FormatValue(parentControl, formattedValue, configurationValues, condensed)); }
/// <summary> /// Formats the filter value value. /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="value">The value.</param> /// <returns></returns> public override string FormatFilterValueValue(Dictionary <string, ConfigurationValue> configurationValues, string value) { string formattedValue = string.Empty; if (!string.IsNullOrWhiteSpace(value)) { var guids = value.SplitDelimitedValues(); var eventCalendars = guids.Select(g => EventCalendarCache.Get(g)); if (eventCalendars.Any()) { formattedValue = string.Join("' OR '", (from eventCalendar in eventCalendars select eventCalendar.Name).ToArray()); } } return(AddQuotes(formattedValue)); }
/// <summary> /// Reads new values entered by the user for the field /// returns EventCalendar.Guid as string /// </summary> /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param> /// <param name="configurationValues">The configuration values.</param> /// <returns></returns> public override string GetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues) { EventCalendarPicker eventCalendarPicker = control as EventCalendarPicker; if (eventCalendarPicker != null) { int?eventCalendarId = eventCalendarPicker.SelectedEventCalendarId; if (eventCalendarId.HasValue) { var eventCalendar = EventCalendarCache.Get(eventCalendarId.Value); if (eventCalendar != null) { return(eventCalendar.Guid.ToString()); } } } return(string.Empty); }
/// <summary> /// Adds the event to a Calendar. /// </summary> /// <param name="eventItem">The event</param> /// <param name="calendar">The calendar</param> /// <param name="created">If a new calendar item was created</param> /// <returns>The calendar item for the event</returns> public static EventCalendarItem AddToCalendar(this EventItem eventItem, EventCalendarCache calendar, out bool created) { created = false; if (calendar == null) { return(null); } var calendarItem = eventItem.EventCalendarItems.FirstOrDefault(ci => ci.EventCalendarId == calendar.Id); if (calendarItem == null) { created = true; calendarItem = new EventCalendarItem { EventCalendarId = calendar.Id }; eventItem.EventCalendarItems.Add(calendarItem); } return(calendarItem); }
/// <summary> /// Gets the filter value control. /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id">The identifier.</param> /// <param name="required">if set to <c>true</c> [required].</param> /// <param name="filterMode">The filter mode.</param> /// <returns></returns> public override Control FilterValueControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode) { var cbList = new RockCheckBoxList(); cbList.ID = string.Format("{0}_cbList", id); cbList.AddCssClass("js-filter-control"); cbList.RepeatDirection = RepeatDirection.Horizontal; var eventCalendarList = EventCalendarCache.All(); if (eventCalendarList.Any()) { foreach (var eventCalendar in eventCalendarList) { ListItem listItem = new ListItem(eventCalendar.Name, eventCalendar.Guid.ToString()); cbList.Items.Add(listItem); } return(cbList); } return(null); }
/// <summary> /// Updates any Cache Objects that are associated with this entity /// </summary> /// <param name="entityState">State of the entity.</param> /// <param name="dbContext">The database context.</param> public void UpdateCache(EntityState entityState, Rock.Data.DbContext dbContext) { EventCalendarCache.UpdateCachedEntity(this.Id, entityState); }
/// <summary> /// Adds test data for Events that can be used to test inherited attributes. /// </summary> private static void InitializeInheritedAttributesTestData() { var rockContext = new RockContext(); var EventCalendarPublicId = EventCalendarCache.All().First(x => x.Name == "Public").Id; var EventCalendarInternalId = EventCalendarCache.All().First(x => x.Name == "Internal").Id; // Add Attributes for Calendars. // EventItem Attributes are defined per Calendar, so they are directly associated with the EventCalendarItem entity. // The Attributes collection for the EventItem shows the collection of attributes inherited from the EventCalendarItems associated with the event. var attributeService = new AttributeService(rockContext); var textFieldTypeId = FieldTypeCache.GetId(SystemGuid.FieldType.TEXT.AsGuid()).GetValueOrDefault(); // Add Attribute A for Internal Calendar. var attributeAInternal = attributeService.Get(InternalCalendarAttribute1Guid.AsGuid()); if (attributeAInternal != null) { attributeService.Delete(attributeAInternal); rockContext.SaveChanges(); } attributeAInternal = new Rock.Model.Attribute(); attributeAInternal.EntityTypeId = EntityTypeCache.GetId(typeof(EventCalendarItem)); attributeAInternal.EntityTypeQualifierColumn = "EventCalendarId"; attributeAInternal.EntityTypeQualifierValue = EventCalendarInternalId.ToString(); attributeAInternal.Name = InternalCalendarAttribute1Key; attributeAInternal.Key = InternalCalendarAttribute1Key; attributeAInternal.Guid = InternalCalendarAttribute1Guid.AsGuid(); attributeAInternal.FieldTypeId = textFieldTypeId; attributeService.Add(attributeAInternal); rockContext.SaveChanges(); // Add Attribute A for Public Calendar. var attributeAPublic = attributeService.Get(PublicCalendarAttribute1Guid.AsGuid()); if (attributeAPublic != null) { attributeService.Delete(attributeAPublic); rockContext.SaveChanges(); } attributeAPublic = new Rock.Model.Attribute(); attributeAPublic.EntityTypeId = EntityTypeCache.GetId(typeof(EventCalendarItem)); attributeAPublic.EntityTypeQualifierColumn = "EventCalendarId"; attributeAPublic.EntityTypeQualifierValue = EventCalendarPublicId.ToString(); attributeAPublic.Name = PublicCalendarAttribute1Key; attributeAPublic.Key = PublicCalendarAttribute1Key; attributeAPublic.Guid = PublicCalendarAttribute1Guid.AsGuid(); attributeAPublic.FieldTypeId = textFieldTypeId; attributeService.Add(attributeAPublic); rockContext.SaveChanges(); // Create a new Event: "Event A". // This event exists in the Internal and Public calendars. var eventItemService = new EventItemService(rockContext); var eventA = eventItemService.Get(EventAGuid.AsGuid()); if (eventA != null) { eventItemService.Delete(eventA); rockContext.SaveChanges(); } eventA = new EventItem(); eventA.Name = "Event A"; eventA.Guid = EventAGuid.AsGuid(); var eventACalendarInternal = new EventCalendarItem { EventCalendarId = EventCalendarInternalId, Guid = EventACalendarInternalGuid.AsGuid() }; var eventACalendarPublic = new EventCalendarItem { EventCalendarId = EventCalendarPublicId, Guid = EventACalendarPublicGuid.AsGuid() }; eventA.EventCalendarItems.Add(eventACalendarInternal); eventA.EventCalendarItems.Add(eventACalendarPublic); eventItemService.Add(eventA); rockContext.SaveChanges(); // Create a new Event: "Event B". // This event exists in the Internal calendar only. // This event is created manually, to set the ID of Event B to match an Event Calendar Item associated with Event A. // The purpose is to create an EventItem and an EventCalendarItem that have an identical ID, // so we can verify that Attribute values for parent and child entities are correctly differentiated // by Entity Type when they are collated for inherited attributes. var eventB = eventItemService.Get(EventBGuid.AsGuid()); if (eventB != null) { eventItemService.Delete(eventB); rockContext.SaveChanges(); } var matchedID = eventACalendarInternal.Id; var sql = @" SET IDENTITY_INSERT [EventItem] ON ; INSERT INTO [EventItem] (Id, Name, Guid, IsActive) VALUES (@p0, @p1, @p2, 1) ; SET IDENTITY_INSERT [EventItem] OFF ; "; rockContext.Database.ExecuteSqlCommand(sql, matchedID, "Event B", EventBGuid.AsGuid()); eventB = eventItemService.Get(EventBGuid.AsGuid()); var eventBCalendarInternal = new EventCalendarItem { EventCalendarId = EventCalendarInternalId, Guid = EventBCalendarInternalGuid.AsGuid() }; var eventBCalendarPublic = new EventCalendarItem { EventCalendarId = EventCalendarPublicId, Guid = EventBCalendarPublicGuid.AsGuid() }; eventB.EventCalendarItems.Add(eventBCalendarInternal); eventB.EventCalendarItems.Add(eventBCalendarPublic); rockContext.SaveChanges(); // Set Attribute Values. rockContext = new RockContext(); AttributeCache.Clear(); // Set Attribute Values for Event B. eventBCalendarPublic.LoadAttributes(rockContext); eventBCalendarPublic.SetAttributeValue(PublicCalendarAttribute1Key, "Event B Public"); eventBCalendarPublic.SaveAttributeValues(rockContext); rockContext.SaveChanges(); // Set Attribute Values for Event A eventACalendarInternal.LoadAttributes(rockContext); eventACalendarInternal.SetAttributeValue(InternalCalendarAttribute1Key, "Event A Internal"); eventACalendarInternal.SaveAttributeValues(rockContext); eventACalendarPublic.LoadAttributes(rockContext); eventACalendarPublic.SetAttributeValue(PublicCalendarAttribute1Key, "Event A Public"); eventACalendarPublic.SaveAttributeValues(rockContext); rockContext.SaveChanges(); }
/// <summary> /// Initializes a new instance of the <see cref="EventCalendarPicker" /> class. /// </summary> public EventCalendarPicker() : base() { Label = "EventCalendar"; EventCalendars = EventCalendarCache.All(); }
public async Task ExecuteAsync(IJobExecutionContext context) { // Get the configuration for the job JobDataMap dataMap = context.JobDetail.JobDataMap; var approvalAttributeGuid = dataMap.GetString(AttributeKey_ApprovedAttribute).AsGuid(); var approvalAttribute = AttributeCache.Get(approvalAttributeGuid); // Collect some values for matching var campuses = CampusCache.All(); var audiences = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.MARKETING_CAMPAIGN_AUDIENCE_TYPE).DefinedValues; // Get the calendars var calendarGuid = dataMap.GetString(AttributeKey_Calendar).AsGuid(); var publicCalendarGuid = dataMap.GetString(AttributeKey_PublicCalendar).AsGuidOrNull(); var calendar = EventCalendarCache.Get(calendarGuid); var publicCalendar = publicCalendarGuid.HasValue ? EventCalendarCache.Get(publicCalendarGuid.Value) : null; // Get the login credentials string eSpaceUsername = dataMap.GetString(AttributeKey_eSpaceUsername); string eSpacePassword = dataMap.GetString(AttributeKey_eSpacePassword); // Decrypt the password eSpacePassword = Rock.Security.Encryption.DecryptString(eSpacePassword); // Create a new api client var client = new Client(); // Log in client.SetCredentials(eSpaceUsername, eSpacePassword); // Get all future events var eSpaceEvents = await client.GetEvents(new GetEventsOptions { StartDate = DateTime.Now, TopX = 2000 }); // Group by event id (the eSpace api returns "events" as a merged event and schedule) var eSpaceEventsById = eSpaceEvents.GroupBy(e => e.EventId); var eventTotalCount = eSpaceEventsById.Count(); // Loop through each eSpace event group var eventSyncedCount = 0; var eventErrorCount = 0; foreach (var eSpaceEventGroup in eSpaceEventsById) { eventSyncedCount++; try { // Use the first item as the main event - Note that some properties // here are actually part of the schedule, not the event var eSpaceEvent = eSpaceEventGroup.FirstOrDefault(); // Skip draft events if (eSpaceEvent.Status == "Draft") { continue; } // Update the job status context.UpdateLastStatusMessage($@"Syncing event {eventSyncedCount} of {eventTotalCount} ({Math.Round( (double) eventSyncedCount / eventTotalCount * 100, 0 )}%, {eventErrorCount} events with errors)"); // Sync the event await SyncHelper.SyncEvent( client, eSpaceEvent, new GetEventOccurrencesOptions { StartDate = DateTime.Now }, calendar, publicCalendar, null, approvalAttribute?.Key ); } catch (Exception ex) { ExceptionLogService.LogException(ex, null); eventErrorCount++; } } var eSpaceEventIds = eSpaceEvents.Select(e => e.EventId).ToArray(); var rockContext = new RockContext(); var eventItemService = new EventItemService(rockContext); var desyncedEvents = eventItemService.Queryable().Where(e => e.ForeignKey == SyncHelper.ForeignKey_eSpaceEventId && !eSpaceEventIds.Contains(e.ForeignId)); if (desyncedEvents.Any()) { eventItemService.DeleteRange(desyncedEvents); rockContext.SaveChanges(); } // Update the job status context.UpdateLastStatusMessage($@"Synced {eventSyncedCount} events with {eventErrorCount} errors."); }
/// <summary> /// Syncs an eSpace event into Rock. /// </summary> /// <param name="eSpaceClient">The eSpace client</param> /// <param name="eSpaceEvent">The eSpace event</param> /// <param name="occurrencesFilter">The filter to use when syncing occurrences</param> /// <returns>The synced Rock event</returns> public static async Task SyncEvent( Client eSpaceClient, ESpace.Event eSpaceEvent, GetEventOccurrencesOptions occurrencesFilter, EventCalendarCache globalCalendar, EventCalendarCache publicCalendar, EventCalendarCache privateCalendar, string occurrenceApprovedAttributeKey ) { using (var rockContext = new RockContext()) { // Create our services var eventItemService = new EventItemService(rockContext); var eventItemOccurrenceService = new EventItemOccurrenceService(rockContext); var eventItemAudienceService = new EventItemAudienceService(rockContext); var scheduleService = new ScheduleService(rockContext); var personService = new PersonService(rockContext); // Get or create the linked Rock event var rockEvent = eventItemService.GetOrCreateByForeignId( "EventCalendarItems,EventItemOccurrences", ForeignKey_eSpaceEventId, eSpaceEvent.EventId.Value, out var _ ); // Track if we needed to update anything var changed = false; // Update the Name if (rockEvent.Name != eSpaceEvent.EventName) { changed = true; rockEvent.Name = eSpaceEvent.EventName; } // Update the Active State var eSpaceEventIsActive = eSpaceEvent.Status != ESpaceStatus_Draft; if (rockEvent.IsActive != eSpaceEventIsActive) { changed = true; rockEvent.IsActive = eSpaceEventIsActive; } // Update the Approval State var eSpaceEventIsApproved = eSpaceEvent.Status == ESpaceStatus_Approved; if (rockEvent.IsApproved != eSpaceEventIsApproved) { changed = true; rockEvent.IsApproved = eSpaceEventIsApproved; if (eSpaceEventIsApproved) { rockEvent.ApprovedOnDateTime = DateTime.Now; } else { rockEvent.ApprovedOnDateTime = null; } } // Update the Summary if (rockEvent.Summary != eSpaceEvent.Description) { changed = true; rockEvent.Summary = eSpaceEvent.Description; } // Update the details Url var eSpaceEventPublicLink = eSpaceEvent.PublicLink?.ToString(); if (rockEvent.DetailsUrl != eSpaceEventPublicLink) { changed = true; rockEvent.DetailsUrl = eSpaceEventPublicLink; } // Update the audiences var eSpaceCategories = MatchCategories(eSpaceEvent.Categories); // Check global calendar if (globalCalendar != null) { rockEvent.AddToCalendar(globalCalendar, out var addedToCalendar); changed = changed || addedToCalendar; } var eventCalendarItemService = new EventCalendarItemService(rockContext); // Check public calendar if (publicCalendar != null) { if (eSpaceEvent.IsPublic ?? false) { rockEvent.AddToCalendar(publicCalendar, out var addedToCalendar); changed = changed || addedToCalendar; } else { rockEvent.RemoveFromCalendar(eventCalendarItemService, publicCalendar, out var removedFromCalendar); changed = changed || removedFromCalendar; } } // Check private calendar if (privateCalendar != null) { if (!(eSpaceEvent.IsPublic ?? false)) { rockEvent.AddToCalendar(privateCalendar, out var addedToCalendar); changed = changed || addedToCalendar; } else { rockEvent.RemoveFromCalendar(eventCalendarItemService, privateCalendar, out var removedFromCalendar); changed = changed || removedFromCalendar; } } // Fetch the occurrences for the event if (occurrencesFilter == null) { occurrencesFilter = new GetEventOccurrencesOptions { StartDate = DateTime.Now } } ; occurrencesFilter.EventId = eSpaceEvent.EventId; var eSpaceEventOccurrences = await eSpaceClient.GetEventOccurrences(occurrencesFilter); // Calculate some stuff for the occurrences var campusLocations = MatchLocations(eSpaceEvent.IsOffSite ?? false ? eSpaceEvent.PublicLocations : eSpaceEvent.Locations); var contactPerson = personService.FindPerson(eSpaceEvent.Contacts.FirstOrDefault()); var firstESpaceOccurrence = eSpaceEventOccurrences.FirstOrDefault(); if (firstESpaceOccurrence != null) { // Update the Description if (rockEvent.Description != firstESpaceOccurrence.PublicHtmlNotes) { rockEvent.Description = firstESpaceOccurrence.PublicHtmlNotes; changed = true; } } var syncedRockOccurrences = new List <EventItemOccurrence>();; var rockOccurrencesWithAttributeChanges = new List <EventItemOccurrence>(); // Update each occurrence foreach (var eSpaceOccurrence in eSpaceEventOccurrences) { foreach (var campusLocation in campusLocations) { var rockOccurrence = SyncOccurrence(eSpaceEvent, eSpaceOccurrence, rockEvent, campusLocation, contactPerson, occurrenceApprovedAttributeKey, out var occurrenceChanged, out var occurrenceAttributeChanged); changed = changed || occurrenceChanged; syncedRockOccurrences.Add(rockOccurrence); if (occurrenceAttributeChanged) { rockOccurrencesWithAttributeChanges.Add(rockOccurrence); } } } // Remove any desynced occurrences var removedOccurrences = rockEvent.EventItemOccurrences.Except(syncedRockOccurrences).ToList(); foreach (var occurrence in removedOccurrences) { rockEvent.EventItemOccurrences.Remove(occurrence); if (occurrence.Schedule != null) { scheduleService.Delete(occurrence.Schedule); occurrence.Schedule = null; } eventItemOccurrenceService.Delete(occurrence); changed = true; } // If anything was updated, save it if (changed) { rockContext.SaveChanges(); } // If any occurrences had attributes modified, save them foreach (var rockOccurrence in rockOccurrencesWithAttributeChanges) { rockOccurrence.SaveAttributeValues(); } } }
/// <summary> /// Gets the cache object associated with this Entity /// </summary> /// <returns></returns> public IEntityCache GetCacheObject() { return(EventCalendarCache.Get(this.Id)); }
/// <summary> /// Adds the event to a Calendar. /// </summary> /// <param name="eventItem">The event</param> /// <param name="calendar">The calendar</param> /// <param name="created">If a new calendar item was created</param> /// <returns>The calendar item for the event</returns> public static void RemoveFromCalendar(this EventItem eventItem, EventCalendarItemService eventCalendarItemService, EventCalendarCache calendar, out bool removed) { removed = false; if (calendar == null) { return; } var calendarItem = eventItem.EventCalendarItems.FirstOrDefault(ci => ci.EventCalendarId == calendar.Id); if (calendarItem != null) { removed = true; eventCalendarItemService.Delete(calendarItem); } }