/// <summary> /// Creates a new domain with a given name. /// </summary> /// <param name="name">The name of the domain to create.</param> /// <returns>Returns the newly created domain.</returns> /// <exception cref="EntityAlreadyExsistsException">Thrown if the domain name is already taken.</exception> public async Task <Domain> CreateDomain(string name) { if (await DomainRepository.GetDomain(name) != null) { throw new EntityAlreadyExsistsException("Domain", name); } return(await DomainRepository.CreateDomain(name)); }
/// <summary> /// Gets a domain by its unique ID. /// </summary> /// <param name="id">ID of the domain to get.</param> /// <returns>Returns the domain.</returns> /// <exception cref="EntityNotFoundException">Thrown if no matching domain could be found.</exception> public async Task <Domain> GetDomain(Guid id) { Domain domain = await DomainRepository.GetDomain(id); if (domain == null) { throw new EntityNotFoundException("Domain", id); } return(domain); }