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); }
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); }
public void Execute(Identity identity) { if (!entityById.Exist <Subscription>(identity)) { throw new EntityNotFoundException(typeof(Subscription), identity); } repository.MakeTransient(identity); }
public virtual void Execute(Retry retry) { if (!entityById.Exist <Retry>(retry.Id.Value)) { throw new EntityNotFoundException(typeof(Retry), retry.Id.Value); } repository.Update(retry); }
public void Execute(Identity id) { if (!entityById.Exist <Retry>(id)) { throw new EntityNotFoundException(typeof(Retry), id); } repository.MakeTransient(id); }
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); } }
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); }
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); }
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); }
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 }); }