/// <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)); }