Exemple #1
0
        public async Task <ModuleResponse> PostBootToBackendApi(Models.BootMessage bootMessage)
        {
            using (var client = ApplicationHttpClient(ApplicationConfig.BackendUri))
            {
                var response = await client.PostAsJsonAsync(BackendServerEndPoint.ModuleBoot, bootMessage);

                if (response.IsSuccessStatusCode)
                {
                    var moduleResponse
                        = await response.Content.ReadAsAsync <ModuleResponse>();

                    return(moduleResponse);
                }

                var ex = ApiException.CreateApiException(response);

                throw ex;
            }
        }
Exemple #2
0
        public async Task <ModuleResponse> PostModuleEvent(Models.ModuleEvent moduleEvent)
        {
            using (var client = ApplicationHttpClient(ApplicationConfig.BackendUri))
            {
                var response = await client.PostAsJsonAsync(BackendServerEndPoint.ModuleEvent, moduleEvent);

                if (response.IsSuccessStatusCode)
                {
                    var moduleResponse
                        = await response.Content.ReadAsAsync <ModuleResponse>();

                    return(moduleResponse);
                }
                else
                {
                    throw ApiException.CreateApiException(response);
                }
            }
        }
        public async Task SynchronizeModules(IModuleRepository moduleRepository)
        {
            var modules = await moduleRepository.GetModules();

            if (modules != null && modules.Count > 0)
            {
                using (var client = ApplicationHttpClient(ApplicationConfig.BackendUri))
                {
                    var response
                        = await client.PostAsJsonAsync
                              (BackendServerEndPoint.SynchronizeModules, modules);

                    if (response.IsSuccessStatusCode == false)
                    {
                        var ex = ApiException.CreateApiException(response);

                        throw ex;
                    }
                }
            }
        }