public ApplicationTenantsResult GetApplicationTenants(ApplicationTenantsQuery query)
 {
     var repositoryService = InProcFactory.CreateInstance<ApplicationRepositoryService, IApplicationRepository>();
     try
     {
         return repositoryService.GetApplicationTenants(query);
     }
     finally
     {
         InProcFactory.CloseProxy(repositoryService);
     }
 }
        public ActionResult Tenants(string applicationName, int startIndex = 0, int pageSize = 50)
        {
            var applicationTenantsModel = new ApplicationTenantsModel
            {
                ApplicationName = applicationName
            };

            var client = new ApplicationManagerClient();
            var query = new ApplicationTenantsQuery() { ApplicationName = applicationName, PageSize = pageSize, StartIndex = startIndex };
            var results = client.GetApplicationTenants(query);

            applicationTenantsModel.TotalCount = results.TotalCount;
            applicationTenantsModel.Tenants = results.Items ?? new ApplicationTenantHeaderInfo[]{};
            
            return View(applicationTenantsModel);
        }
        public ApplicationTenantsResult GetApplicationTenants(ApplicationTenantsQuery query)
        {
            var result = new ApplicationTenantsResult();

            UseDataContext(dataContext =>
            {
                dataContext.ObjectTrackingEnabled = false;

                var searchQuery = dataContext.ApplicationTenants.Where(tenant => tenant.Application == query.ApplicationName);
                result.TotalCount = searchQuery.Count();
                searchQuery = searchQuery.Skip(query.StartIndex).Take(query.PageSize);
                result.Items = searchQuery.Select(MapDataApplicationTenant).ToArray();
            });

            return result;
        }