public Entities.Server GetOrCreate(IDaoFactory daoFactory) { var serverDao = daoFactory.CreateServerDao(); var linkedServer = serverDao.Get(Tenant); if (linkedServer != null) { return(linkedServer); } var servers = GetAllServers(daoFactory); if (!servers.Any()) { throw new Exception("Mail Server not configured"); } var server = servers.First(); Link(daoFactory, server, Tenant); linkedServer = server; return(linkedServer); }
private static List <Entities.Server> GetAllServers(IDaoFactory daoFactory) { var serverDao = daoFactory.CreateServerDao(); var servers = serverDao.GetList(); return(servers); }
public void Link(IDaoFactory daoFactory, Entities.Server server, int tenant) { if (server == null) { return; } var serverDao = daoFactory.CreateServerDao(); var result = serverDao.Link(server, Tenant); if (result <= 0) { throw new Exception("Invalid insert operation"); } }