예제 #1
0
        public async Task <ApiResponse <MinigameOverviewDto> > SaveMinigameOverview(MinigameOverviewSendDto minigameOverview)
        {
            var requestUrl = $"{_baseUrl}/{MinigamesUrl}";

            var jsonContent   = JsonConvert.SerializeObject(minigameOverview);
            var contentString = new StringContent(jsonContent, Encoding.UTF8, "application/json");

            HttpResponseMessage response;

            try
            {
                var request = new HttpRequestMessage(HttpMethod.Post, requestUrl);
                request.Headers.Add("GameToken", _gameToken);
                request.Content = contentString;
                response        = await HTTP_CLIENT.SendAsync(request);
            }
            catch (HttpRequestException httpRequestException)
            {
                Debug.LogWarning($"No internet connection!. Error: {httpRequestException}");
                return(new ApiResponse <MinigameOverviewDto>());
            }

            if (!response.IsSuccessStatusCode)
            {
                return(new ApiResponse <MinigameOverviewDto>());
            }

            var stringResponse = response.Content.ReadAsStringAsync().Result;
            var apiResponse    = JsonConvert.DeserializeObject <ApiResponse <MinigameOverviewDto> >(stringResponse);

            return(apiResponse);
        }
예제 #2
0
        private void Awake()
        {
            scp = FindObjectOfType <SerialControllerPitaco>();
            scm = FindObjectOfType <SerialControllerMano>();
            scc = FindObjectOfType <SerialControllerCinta>();
            sco = FindObjectOfType <SerialControllerOximetro>();


            _minigameOverviewSendDto = new MinigameOverviewSendDto {
                FlowDataRound = new List <FlowDataMinigame>()
            };
            _pitacoLogger   = FindObjectOfType <PitacoLogger>();
            _manoLogger     = FindObjectOfType <ManoLogger>();
            _cintaLogger    = FindObjectOfType <CintaLogger>();
            _oximetroLogger = FindObjectOfType <OximetroLogger>();
        }
예제 #3
0
        public async Task <DataManagerReponse <MinigameOverviewDto, MinigameOverviewSendDto> > SaveMinigameOverview(MinigameOverviewSendDto minigame)
        {
            var response = new DataManagerReponse <MinigameOverviewDto, MinigameOverviewSendDto>();

            LocalDataManager.Instance.SaveLocalData("MinigameOverview", minigame, Pacient.Loaded.Name);

            if (!ConfigurationManager.SendRemoteData || string.IsNullOrWhiteSpace(ConfigurationManager.GameApiToken))
            {
                return(response);
            }

            var hasInternetConnection = await ApiClient.Instance.HasInternetConnection();

            if (!hasInternetConnection)
            {
                LocalDataManager.Instance.SaveRemoteData("MinigameOverview", minigame, Pacient.Loaded.IdApi);
                response.LocalResponse = minigame;
                return(response);
            }
            response.ApiResponse = await ApiClient.Instance.SaveMinigameOverview(minigame);

            return(response);
        }