/// <summary>
        /// Create a new draft notification.
        /// </summary>
        /// <param name="notificationRepository">The notification repository.</param>
        /// <param name="notification">Draft Notification model class instance passed in from Web API.</param>
        /// <param name="userName">Name of the user who is running the application.</param>
        /// <returns>The newly created notification's id.</returns>
        public static async Task <string> CreateDraftNotificationAsync(
            this NotificationDataRepository notificationRepository,
            DraftNotification notification,
            string userName)
        {
            var newId = notificationRepository.TableRowKeyGenerator.CreateNewKeyOrderingOldestToMostRecent();

            var notificationEntity = new NotificationDataEntity
            {
                PartitionKey = NotificationDataTableNames.DraftNotificationsPartition,
                RowKey       = newId,
                Id           = newId,
                Title        = notification.Title,
                ImageLink    = notification.ImageLink,
                Summary      = notification.Summary,
                Author       = notification.Author,
                ButtonTitle  = notification.ButtonTitle,
                ButtonLink   = notification.ButtonLink,
                CreatedBy    = userName,
                CreatedDate  = DateTime.UtcNow,
                IsDraft      = true,
                Teams        = notification.Teams,
                Rosters      = notification.Rosters,
                Groups       = notification.Groups,
                AllUsers     = notification.AllUsers,
            };

            await notificationRepository.CreateOrUpdateAsync(notificationEntity);

            return(newId);
        }
Esempio n. 2
0
        /// <summary>
        /// Create a new draft notification.
        /// </summary>
        /// <param name="notificationRepository">The notification repository.</param>
        /// <param name="notification">Draft Notification model class instance passed in from Web API.</param>
        /// <param name="userName">Name of the user who is running the application.</param>
        /// <returns>The newly created notification's id.</returns>
        public static async Task <string> CreateDraftNotificationAsync(
            this NotificationDataRepository notificationRepository,
            DraftNotification notification,
            string userName)
        {
            var newId = notificationRepository.TableRowKeyGenerator.CreateNewKeyOrderingOldestToMostRecent();

            var notificationEntity = new NotificationDataEntity
            {
                PartitionKey    = PartitionKeyNames.NotificationDataTable.DraftNotificationsPartition,
                RowKey          = newId,
                Id              = newId,
                Title           = notification.Title,
                ImageLink       = notification.ImageLink,
                Summary         = notification.Summary,
                Author          = notification.Author,
                ButtonTitle     = notification.ButtonTitle,
                ButtonLink      = notification.ButtonLink,
                ButtonTitle2    = notification.ButtonTitle2,
                ButtonLink2     = notification.ButtonLink2,
                CreatedBy       = userName,
                CreatedDate     = DateTime.UtcNow,
                IsDraft         = true,
                Teams           = notification.Teams,
                Rosters         = notification.Rosters,
                ADGroups        = notification.ADGroups,
                AllUsers        = notification.AllUsers,
                IsScheduled     = notification.IsScheduled,
                ScheduleDate    = notification.ScheduleDate,
                IsRecurrence    = notification.IsRecurrence,
                Repeats         = notification.Repeats,
                RepeatFor       = Convert.ToInt32(notification.RepeatFor),
                RepeatFrequency = notification.RepeatFrequency,
                WeekSelection   = notification.WeekSelection,
                RepeatStartDate = notification.RepeatStartDate,
                RepeatEndDate   = notification.RepeatEndDate,
            };

            await notificationRepository.CreateOrUpdateAsync(notificationEntity);

            return(newId);
        }