public async Task <ActionResult> SaveNotification(NotificationDetailsViewModel model)
        {
            //ModelState.AddModelError("EmailSubject", "Test Error.");

            if (ModelState.IsValid)
            {
                model.Title = BuildNotificationTitle(model);

                if (model.ScheduleAction == NotificationDetailsViewModel.ScheduleActions.Draft)
                {
                    model.Status = NotificationStatus.Draft;
                }
                else if (model.ScheduleAction == NotificationDetailsViewModel.ScheduleActions.SendNow)
                {
                    model.Status      = NotificationStatus.Scheduled;
                    model.TimeZoneId  = TimeZoneHelper.DefaultTimeZoneId; // TO DO: Get the time zone from the user context.
                    model.ScheduledDT = TimeZoneHelper.Now(model.TimeZoneId);
                }
                else
                {
                    model.Status = NotificationStatus.Scheduled;
                }

                var userGroupIds = new List <string>();
                userGroupIds.AddRange(model.NotificationGroupIds);
                userGroupIds.AddRange(model.ConnectionGroupIds);

                if (string.IsNullOrEmpty(model.Id))
                {
                    model.Id         = Guid.NewGuid().ToString("N");
                    model.CreatedUTC = DateTime.UtcNow;
                    model.CreatedBy  = User.GetUserId();
                    var insertNote = model.ProjectTo <Angelo.Connect.Models.Notification>();
                    await _notificationManager.InsertNotificationAsync(insertNote, userGroupIds);
                }
                else
                {
                    var updateNote = model.ProjectTo <Angelo.Connect.Models.Notification>();
                    await _notificationManager.UpdateNotificationAsync(updateNote, userGroupIds);
                }

                if (model.ScheduleAction == NotificationDetailsViewModel.ScheduleActions.SendNow)
                {
                    await _jobs.EnqueueAsync <NotificationProcessor>(proc => proc.ExecuteNotification(model.Id));

                    model.Status = NotificationStatus.Processing;
                }

                return(Ok(model));
            }
            return(BadRequest(ModelState));
        }