Exemplo n.º 1
0
        /// <summary>
        /// Sends cancellation notification to the registered users for an event
        /// </summary>
        /// <param name="eventDetails">List of events details.</param>
        /// <param name="notificationType">The type of notification being sent</param>
        private async Task SendReminder(IEnumerable <EventEntity> eventDetails, NotificationType notificationType)
        {
            var userList = new List <string>();

            await this.categoryHelper.BindCategoryNameAsync(eventDetails);

            userList.AddRange(eventDetails.Select(eventdetails => eventdetails.GetAttendees()).First());
            if (userList.Any())
            {
                userList = userList.Distinct().ToList();
                var registeredAttendees = await this.userConfigurationRepository.GetUserConfigurationsAsync(userList);

                foreach (var user in registeredAttendees)
                {
                    var filteredEvents = eventDetails.Where(eventDetails => (eventDetails.AutoRegisteredAttendees != null && eventDetails.AutoRegisteredAttendees.Contains(user.AADObjectId, StringComparison.OrdinalIgnoreCase)) ||
                                                            (eventDetails.RegisteredAttendees != null && eventDetails.RegisteredAttendees.Contains(user.AADObjectId, StringComparison.OrdinalIgnoreCase)));

                    if (!filteredEvents.IsNullOrEmpty())
                    {
                        var card = ReminderCard.GetCard(filteredEvents, this.localizer, this.botOptions.Value.ManifestId, notificationType);
                        await this.notificationHelper.SendNotificationToUsersAsync(new List <User> {
                            user
                        }, card);
                    }
                }
            }
        }
        public void GetCard()
        {
            var Results = ReminderCard.GetCard(new List <EventEntity> {
                EventWorkflowHelperData.validEventEntity
            }, localizer.Object, "random", NotificationType.Manual);

            Assert.AreEqual(Results.ContentType, AdaptiveCard.ContentType);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sends reminder to the registered users for an event
        /// </summary>
        /// <param name="teamId">The LnD team Id</param>
        /// <param name="eventId">The event Id for which notification to send</param>
        /// <returns>Returns the list of user Ids to whom notification send was failed</returns>
        public async Task SendReminderAsync(string teamId, string eventId)
        {
            var eventDetails = await this.eventRepository.GetEventDetailsAsync(eventId, teamId);

            if (eventDetails == null || eventDetails.RegisteredAttendeesCount == 0)
            {
                return;
            }

            var registeredAttendees = await this.userConfigurationRepository.GetUserConfigurationsAsync(eventDetails.GetAttendees());

            await this.categoryHelper.BindCategoryNameAsync(new List <EventEntity>() { eventDetails });

            var notificationCard = ReminderCard.GetCard(new List <EventEntity>()
            {
                eventDetails
            }, this.localizer, this.botOptions.Value.ManifestId);

            await this.notificationHelper.SendNotificationToUsersAsync(registeredAttendees, notificationCard);
        }