Exemplo n.º 1
0
        public virtual void Execute(Topic topic)
        {
            if (!topic.Id.HasValue)
            {
                throw new ValidationException(Texts.IdMustNotBeNull);
            }
            if (!entityById.Exist <Topic>(topic.Id.Value))
            {
                throw new EntityNotFoundException(typeof(Topic), topic.Id.Value);
            }
            if (string.IsNullOrWhiteSpace(topic.Name))
            {
                throw new ValidationException(Texts.NameMustBeNotNull);
            }
            if (existsTopicByName.Execute(topic.GroupId, topic.Name, topic.Id))
            {
                throw new ValidationException(Texts.TopicNameMustBeUnique, topic.Name);
            }
            if (topic.GroupId.HasValue && !entityById.Exist <Group>(topic.GroupId.Value))
            {
                throw new ValidationException(Texts.EntityNotFound, typeof(Group).Name, topic.GroupId);
            }

            repository.Update(topic);
        }
Exemplo n.º 2
0
        public void Execute(Group group)
        {
            if (!group.Id.HasValue)
            {
                throw new ValidationException(Texts.IdMustNotBeNull);
            }
            if (!entityById.Exist <Group>(group.Id.Value))
            {
                throw new EntityNotFoundException(typeof(Group), group.Id.Value);
            }
            if (string.IsNullOrWhiteSpace(group.Name))
            {
                throw new ValidationException(Texts.NameMustBeNotNull);
            }
            if (existGroupByGroupName.Execute(group.Name, group.Id))
            {
                throw new ValidationException(Texts.GroupNameMustBeUnique, group.Name);
            }
            if (group.ParentId.HasValue && !entityById.Exist <Group>(group.ParentId.Value))
            {
                throw new ValidationException(Texts.EntityNotFound);
            }

            ValidateCircleReferences(group);
            repository.Update(group);
        }
Exemplo n.º 3
0
 public void Execute(Identity identity)
 {
     if (!entityById.Exist <Subscription>(identity))
     {
         throw new EntityNotFoundException(typeof(Subscription), identity);
     }
     repository.MakeTransient(identity);
 }
Exemplo n.º 4
0
        public virtual void Execute(Retry retry)
        {
            if (!entityById.Exist <Retry>(retry.Id.Value))
            {
                throw new EntityNotFoundException(typeof(Retry), retry.Id.Value);
            }

            repository.Update(retry);
        }
Exemplo n.º 5
0
        public void Execute(Identity id)
        {
            if (!entityById.Exist <Retry>(id))
            {
                throw new EntityNotFoundException(typeof(Retry), id);
            }

            repository.MakeTransient(id);
        }
Exemplo n.º 6
0
 private void Validate(Subscription subscription)
 {
     if (!subscription.Id.HasValue)
     {
         throw new ValidationException(Texts.IdMustNotBeNull);
     }
     if (!entityById.Exist <Subscription>(subscription.Id.Value))
     {
         throw new EntityNotFoundException(typeof(Subscription), subscription.Id.Value);
     }
 }
Exemplo n.º 7
0
 public void Execute(Subscription subscription)
 {
     if (subscription.TargetId == null)
     {
         throw new ValidationException(Texts.TargetIdMustNotBeNull);
     }
     if (!entityById.Exist <Topic>(subscription.TargetId.Value))
     {
         throw new EntityNotFoundException(typeof(Topic), subscription.TargetId.Value);
     }
     repository.MakePersistent(subscription);
 }
Exemplo n.º 8
0
 public void Execute(Identity id)
 {
     if (!entityById.Exist <Group>(id))
     {
         throw new EntityNotFoundException(typeof(Group), id);
     }
     if (childGroupsOfGroup.HasChilds(id))
     {
         throw new ValidationException(string.Format(Texts.GroupContainsChildGroups, id));
     }
     if (topicsByGroup.HasTopics(id))
     {
         throw new ValidationException(string.Format(Texts.GroupContainsChildTopics, id));
     }
     repository.MakeTransient(id);
 }
Exemplo n.º 9
0
        public void Execute(Group group)
        {
            if (string.IsNullOrWhiteSpace(group.Name))
            {
                throw new ValidationException(Texts.NameMustBeNotNull);
            }
            if (existGroupByGroupName.Execute(group.Name))
            {
                throw new ValidationException(Texts.GroupNameMustBeUnique, group.Name);
            }
            if (group.ParentId.HasValue && !entityById.Exist <Group>(group.ParentId.Value))
            {
                throw new ValidationException(Texts.EntityNotFound);
            }

            repository.MakePersistent(group);
        }
Exemplo n.º 10
0
        public virtual void Execute(Message instance)
        {
            if (instance.UtcReceivedOn == default(DateTime))
            {
                throw new ValidationException(Texts.ReceivedOnMustBeSetted);
            }
            if (!entityById.Exist <Topic>(instance.TopicId))
            {
                throw new EntityNotFoundException(typeof(Topic), instance.TopicId);
            }

            repository.MakePersistent(instance);

            eventAggregator.Raise(new NewMessageEvent {
                Message = instance
            });
        }