protected override void ProcessAuthorized(UpdateNotificationRuleCommand command)
        {
            var rule = _notificationRuleRepository.GetById(command.RuleId);

            rule.Query = command.Query;

            _notificationRuleRepository.Save();
        }
        public long Create(long projectId,
                           string name,
                           string query,
                           string description = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (string.IsNullOrEmpty(query))
            {
                throw new ArgumentNullException(nameof(query));
            }

            if (_notificationRuleRepository.Get(projectId, name).Any())
            {
                throw new NotificationAlreadyExistsException(projectId, name);
            }

            var rule = new NotificationRules
            {
                ProjectId   = projectId,
                Added       = _timeService.GetUtc(),
                Description = description,
                DisplayName = name,
                Query       = query
            };

            _notificationRuleRepository.Insert(rule);

            _notificationRuleRepository.Save();

            _log.Info(Properties.Resources.NotificationHasBeenCreated.FormatWith(rule.Id, name));

            return(rule.Id);
        }