/// <summary>
        /// Helper function (may return null if the JSON content could not be parsed)
        /// </summary>
        public static PushToSend FromEntity(PushNotificationForSave e, int tenantId)
        {
            PushContent content;

            try
            {
                content = JsonSerializer.Deserialize <PushContent>(e.Content, _serializerOptions);
            }
            catch
            {
                return(null); // Should not happen in theory but just in case
            }

            return(new PushToSend
            {
                Auth = e.Auth,
                Endpoint = e.Endpoint,
                P256dh = e.P256dh,
                Content = content,

                PushId = e.Id,
                TenantId = tenantId
            });
        }
Beispiel #2
0
        /// <summary>
        ///  Helper function (may return null if the JSON content could not be parsed)
        /// </summary>
        public static PushNotification FromEntity(PushNotificationForSave e, int tenantId)
        {
            PushNotificationInfo content;

            try
            {
                content = JsonConvert.DeserializeObject <PushNotificationInfo>(e.Content);
            }
            catch
            {
                return(null); // Should not happen in theory but just in case
            }

            return(new PushNotification
            {
                Auth = e.Auth,
                Endpoint = e.Endpoint,
                P256dh = e.P256dh,
                Content = content,

                PushId = e.Id,
                TenantId = tenantId
            });
        }