public void DeleteEventRoomsForEvent(int eventId, string token) { // get event room ids var discardedEventRoomIds = GetRoomReservations(eventId).Select(r => r.EventRoomId).ToArray(); // MP will throw an error if there are no elements to delete, so we need to exit the function before then if (discardedEventRoomIds.Length == 0) { return; } // create selection for event groups SelectionDescription eventRoomSelDesc = new SelectionDescription(); eventRoomSelDesc.DisplayName = "DiscardedEventRooms " + DateTime.Now; eventRoomSelDesc.Kind = SelectionKind.Normal; eventRoomSelDesc.PageId = _configurationWrapper.GetConfigIntValue("RoomReservationPageId"); var eventRoomSelId = _ministryPlatformService.CreateSelection(eventRoomSelDesc, token); // add events to selection _ministryPlatformService.AddToSelection(eventRoomSelId, discardedEventRoomIds, token); // delete the selection records _ministryPlatformService.DeleteSelectionRecords(eventRoomSelId, token); // delete the selection _ministryPlatformService.DeleteSelection(eventRoomSelId, token); }
public void DeleteEventGroupsForEvent(int eventId, string token, int?groupTypeID = null) { // get event group ids var discardedEventGroupIds = groupTypeID == null ? GetEventGroupsForEvent(eventId, token).Select(r => r.EventGroupId).ToArray() : GetEventGroupsForEvent(eventId, token).Where(r => r.GroupTypeId == groupTypeID).Select(r => r.EventGroupId).ToArray(); // MP will throw an error if there are no elements to delete, so we need to exit the function before then if (discardedEventGroupIds.Length == 0) { return; } // create selection for event groups SelectionDescription eventGroupSelDesc = new SelectionDescription(); eventGroupSelDesc.DisplayName = "DiscardedEventGroups " + DateTime.Now; eventGroupSelDesc.Kind = SelectionKind.Normal; eventGroupSelDesc.PageId = _eventGroupsPageId; var eventGroupSelId = _ministryPlatformService.CreateSelection(eventGroupSelDesc, token); // add events to selection _ministryPlatformService.AddToSelection(eventGroupSelId, discardedEventGroupIds, token); // delete the selection records _ministryPlatformService.DeleteSelectionRecords(eventGroupSelId, token); // delete the selection _ministryPlatformService.DeleteSelection(eventGroupSelId, token); }
public int CreateSelection(SelectionDescription selectionDescription, string token) { return(Call <int>(token, platformClient => platformClient.CreateSelection(selectionDescription))); }