Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nt"></param>
        /// <returns></returns>
        public static EntityAlertNotification ToEntity(this ModelAlertNotification nt)
        {
            var e = new EntityAlertNotification()
            {
                Id        = nt.Id,
                Uid       = nt.Uid,
                OrgId     = nt.OrgId,
                IsDefault = nt.IsDefault,
                Name      = nt.Name,
                Type      = nt.Type.ToString(),

                DisableResolveMessage = nt.DisableResolveMessage,
                SendReminder          = nt.SendReminder,
                IncludeImage          = nt.IncludeImage,
                SendOnAllAlerts       = nt.SendOnAllAlerts
            };

            if (string.IsNullOrEmpty(e.Uid))
            {
                e.Uid = TestFactory.GetUid();
            }

            e.JsonData = JsonConvert.SerializeObject(nt, new JsonSerializerSettings()
            {
                ContractResolver = new AlertNotificationPropertiesJsonResolver(true)
            });

            return(e);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public ModelAlertNotification ToModel()
        {
            ModelAlertNotification nt = null;

            try
            {
                var target = typeof(ModelAlertNotification)
                             .Assembly
                             .FindTypesWithCustomAttribute <AlertNotificationTypeAttribute>()
                             .FirstOrDefault(x => 0 == string.Compare(x.Item2.Type, Type, true));

                if (null == target)
                {
                    return(nt);                    // check for plugins in neighbour dll's: todo
                }
                var type = target.Item1;

                nt = JsonConvert.DeserializeObject(JsonData, type) as ModelAlertNotification;

                if (null == nt)
                {
                    return(nt);
                }

                nt.Id        = Id;
                nt.Uid       = Uid;
                nt.IsDefault = IsDefault;
                nt.Name      = Name;
                nt.OrgId     = OrgId;
                nt.Type      = Type;

                nt.DisableResolveMessage = DisableResolveMessage;
                nt.SendReminder          = SendReminder;
                nt.IncludeImage          = IncludeImage;
                nt.SendOnAllAlerts       = SendOnAllAlerts;
            }
            catch
            { }

            return(nt);
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        public void Update(ModelAlertNotification nt)
        {
            Name = nt.Name;

            DisableResolveMessage = nt.DisableResolveMessage;
            SendReminder          = nt.SendReminder;
            SendOnAllAlerts       = nt.SendOnAllAlerts;
            IncludeImage          = nt.IncludeImage;
            IsDefault             = nt.IsDefault;
            Type = nt.Type;

            if (!string.IsNullOrEmpty(nt.Uid))
            {
                Uid = nt.Uid;
            }

            JsonData = JsonConvert.SerializeObject(nt, new JsonSerializerSettings()
            {
                ContractResolver = new AlertNotificationPropertiesJsonResolver(true)
            });
        }
 public async Task <IActionResult> Test(ModelAlertNotification nt) =>
 (await AlertNotificationDispatcher
  .Test(nt))
 .ToActionResult(x => new { Message = "Test notification sent" });
 public IActionResult Update(string uid, ModelAlertNotification nt) =>
 Repo
 .Update(uid, nt)
 .Finalize(() => Reload())
 .ToActionResult();
 public IActionResult Create(ModelAlertNotification nt) =>
 Repo
 .Create(nt)
 .Finalize(() => Reload())
 .ToActionResult();