Exemplo n.º 1
0
        public async Task Rename(Concept concept, string newName, CancellationToken cancellationToken)
        {
            var existing = await _conceptRepository.GetByName(newName, cancellationToken);

            if (existing != null && existing.ConceptId != concept.ConceptId)
            {
                throw new DomainValidationException($"A concept named {newName} already exists.");
            }
            concept.Rename(newName);
        }
Exemplo n.º 2
0
        public async Task Add(Concept concept, CancellationToken cancellationToken = default(CancellationToken))
        {
            var existing = await _conceptRepository.GetByName(concept.Name, cancellationToken);

            if (existing != null)
            {
                throw new DomainValidationException($"A concept named {concept.Name} already exists.");
            }

            await _conceptRepository.Create(concept, cancellationToken);
        }