public JsonResult SavingNotificationConfiguration(NotificationConfigurationSetupModel model)
        {
            if (ModelState.IsValid)
            {
                return(Json(_notificationService.SaveNotificationConfiguration(model)));
            }

            return(Json(new ResponseModel
            {
                Success = false,
                Message = ModelState.BuildValidationMessages()
            }));
        }
Example #2
0
        /// <summary>
        /// Save contact group, notification template and notification send time
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveNotificationConfiguration(NotificationConfigurationSetupModel model)
        {
            var notification = GetById(model.Id);

            if (notification != null)
            {
                // Save contact group
                if (!string.IsNullOrEmpty(model.ContactGroupName))
                {
                    var contactGroup = new ContactGroupManageModel
                    {
                        Name    = model.ContactGroupName,
                        Queries = notification.ContactQueries
                    };

                    _contactGroupService.SaveContactGroup(contactGroup);
                }

                // Save notification template
                if (!string.IsNullOrEmpty(model.NotificationTemplateName))
                {
                    var notificationTemplateManageModel = new NotificationTemplateManageModel
                    {
                        Name              = model.ContactGroupName,
                        Body              = notification.NotificationBody,
                        Subject           = notification.NotificationSubject,
                        Module            = notification.Module,
                        IsDefaultTemplate = false
                    };

                    _notificationTemplateService.SaveNotificationTemplate(notificationTemplateManageModel);
                }

                // Save notification send time and active record
                notification.SendTime = model.SendTime.HasValue ? model.SendTime : DateTime.UtcNow;
                notification.Active   = true;

                var response = Update(notification);

                return(response.Success
                    ? response.SetMessage(T("Notification_Message_SavingNotificationConfigrationSuccessfully"))
                    : response.SetMessage(T("Notification_Message_SavingNotificationConfigrationFailure")));
            }

            return(new ResponseModel
            {
                Success = false,
                Message = T("Notification_Message_ObjectNotFound")
            });
        }