Beispiel #1
0
        public static ManagedAppSubscriberInfo FromNotification(Notification notification)
        {
            var retval = new ManagedAppSubscriberInfo()
            {
                Plan           = notification.Plan.Name,
                Product        = notification.Plan.Product,
                Version        = notification.Plan.Version,
                ApplicationId  = notification.ApplicationId,
                InstallTime    = notification.EventTime,
                LastUpdateTime = DateTime.MinValue,
            };

            return(retval);
        }
        private static async Task <ManagedAppSubscriberInfo> SaveSubscriberAsync(Notification data, ILogger log)
        {
            try
            {
                var container = await GetContainerAsync();

                var record = ManagedAppSubscriberInfo.FromNotification(data);
                await container.UpsertItemAsync <ManagedAppSubscriberInfo>(record, new PartitionKey(record.Product));

                return(record);
            }
            catch (Exception ex)
            {
                log.LogError(ex, "Issue saving subscription info");
                return(null);
            }
        }
        private static async Task <bool> RemoveSubscriber(Notification data, ILogger log)
        {
            try
            {
                var container = await GetContainerAsync();

                var record = ManagedAppSubscriberInfo.FromNotification(data);
                await container.DeleteItemAsync <ManagedAppSubscriberInfo>(record.Id, new PartitionKey(record.Product));

                return(true);
            }
            catch (Exception ex)
            {
                log.LogError(ex, "Issue saving subscription info");
                return(false);
            }
        }