public async Task <IdentityResource> Map(CreateOrUpdateIdentityResourceCommand command) { var identityResource = Mapper.Map <CreateOrUpdateIdentityResourceCommand, IdentityResource>(command); if (string.IsNullOrEmpty(command.Id)) { identityResource.Id = Guid.NewGuid().ToString(); } else { var exist = await _repository.GetById(identityResource.Id); if (!exist.Enabled) { throw new Exception("IdentityResource can't be enabled with this command."); } identityResource.Name = exist.Name; } return(identityResource); }