Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private static List <Entities.Server> GetAllServers(IDaoFactory daoFactory)
        {
            var serverDao = daoFactory.CreateServerDao();

            var servers = serverDao.GetList();

            return(servers);
        }
Ejemplo n.º 3
0
        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");
            }
        }