public override ICollection <IWebDomain> GetWebDomains(IMailServerFactory factory) { if (factory == null) { throw new ArgumentNullException("factory"); } var domainsDtoList = TeamlabDomainDal.GetTenantDomains(); if (!domainsDtoList.Any()) { return(new Collection <IWebDomain>()); } var domainsBaseList = _GetWebDomains(domainsDtoList.ConvertAll(d => d.name)); var webDomains = domainsBaseList.Select(domainBase => { var domainDto = domainsDtoList.Find(dalDomain => dalDomain.name == domainBase.Name); var webdomain = factory.CreateWebDomain(domainDto.id, domainDto.tenant, domainDto.name, domainDto.is_virified, this); return(webdomain); }).OrderBy(obj => obj.Tenant).ToList(); return(webDomains); }
public override IWebDomain GetWebDomain(int domainId, IMailServerFactory factory) { if (domainId < 0) { throw new ArgumentException("domain_id has negative value", "domainId"); } if (factory == null) { throw new ArgumentNullException("factory"); } var domainDto = TeamlabDomainDal.GetDomain(domainId); if (domainDto == null) { throw new Exception("Domain is missing"); } var domainBase = _GetWebDomain(domainDto.name); if (domainBase == null) { throw new Exception("Server domain is missing"); } var webdomain = factory.CreateWebDomain(domainDto.id, domainDto.tenant, domainDto.name, domainDto.is_virified, this); return(webdomain); }
public override IWebDomain CreateWebDomain(string name, bool isVerified, IMailServerFactory factory) { if (factory == null) { throw new ArgumentNullException("factory"); } WebDomainDto domainDto; using (var dbContextWithTran = TeamlabDomainDal.CreateMailDbContext(true)) { domainDto = TeamlabDomainDal.AddWebDomain(name, isVerified, dbContextWithTran.DbManager); _CreateWebDomain(name); dbContextWithTran.CommitTransaction(); } var webdomain = factory.CreateWebDomain(domainDto.id, domainDto.tenant, domainDto.name, domainDto.is_virified, this); return(webdomain); }
public override void DeleteWebDomain(IWebDomain webDomain, IMailServerFactory factory) { if (webDomain == null) { throw new ArgumentNullException("webDomain", "ServerModel::DeleteWebDomain"); } if (factory == null) { throw new ArgumentNullException("factory", "ServerModel::DeleteWebDomain"); } using (var dbContextWithTran = TeamlabDomainDal.CreateMailDbContext(true)) { TeamlabDomainDal.DeleteDomain(webDomain.Id, dbContextWithTran.DbManager); _DeleteWebDomain(new WebDomainBase(webDomain)); TeamlabDnsDal.RemoveUsedDns(webDomain.Id, dbContextWithTran.DbManager); dbContextWithTran.CommitTransaction(); } }
public override bool IsDomainExists(string name) { var domain = TeamlabDomainDal.GetDomain(name); return(domain != null); }