public ActionResult Create(NotificationTemplateManageModel model, SubmitType submit)
        {
            if (ModelState.IsValid)
            {
                var response = _notificationTemplateService.SaveNotificationTemplate(model);
                SetResponseMessage(response);
                if (response.Success)
                {
                    var templateId = (int)response.Data;
                    switch (submit)
                    {
                    case SubmitType.Save:
                        return(RedirectToAction("Index"));

                    case SubmitType.SaveAndContinueEdit:
                        return(RedirectToAction("Edit", new { id = templateId }));
                    }
                }
            }
            return(View(model));
        }
Esempio n. 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")
            });
        }