public async Task<ResultSingle<AppDomain>> CreateDomainAsync(AppDomain domain = null, bool doCache = false, bool throwIfError = true) { AppDomain theDomain = domain == null ? _editDomain : domain; ResultSingle<AppDomain> result = await ResultSingleUI<AppDomain>.WaitForObjectAsync( throwIfError, theDomain, new CachedHttpRequest<AppDomain, ResultSingle<AppDomain>>( Backend.CreateAsync), doCache); if (result.Code >= 0) { _editDomain = result.Data.Payload; // Add the default free certificate AppDomainCertificate cert = new AppDomainCertificate(); cert.OwnedBy = _editDomain; cert.Tag = _editDomain.Tag; cert.Type = "free"; await CreateDomainCertificateAsync(cert); if (domain != null) { _editDomain.CopyTo(domain); _domains.Add(domain); OnPropertyChanged("Domains"); } } return result; }
public async Task<ResultSingle<AppDomain>> QueryDomainAsync(AppDomain domain = null, bool doCache = false, bool throwIfError = true) { AppDomain theDomain = domain == null ? _editDomain : domain; ResultSingle<AppDomain> result = await ResultSingleUI<AppDomain>.WaitForObjectAsync( throwIfError, theDomain, new CachedHttpRequest<AppDomain, ResultSingle<AppDomain>>( Backend.QueryAsync), doCache, null, null); if (result.Code >= 0) { _editDomain = result.Data.Payload; AppDomainCertificate seedCert = new AppDomainCertificate(); seedCert.OwnedBy = _editDomain; ResultMultiple<AppDomainCertificate> certResult = await ResultMultipleUI<AppDomainCertificate>.WaitForObjectsAsync( true, seedCert, new CachedHttpRequest<AppDomainCertificate, ResultMultiple<AppDomainCertificate>>( Backend.QueryAsyncListAsync), true); if (certResult.Code >= 0) { ObservableCollection<AppDomainCertificate> list = certResult.Data.Payload; if (list.Any()) { theDomain.Certificate = list.First(); theDomain.Certificate.OwnedBy = theDomain; } } if (domain != null) { _editDomain.CopyTo(domain); } } return result; }