Beispiel #1
0
        public async Task <bool> IsLoggedIn()
        {
            string authData = await _interopService.GetLocalStorageItem("auth");

            await _logger.Info($"auth data internals: {authData}");

            return(!string.IsNullOrEmpty(authData) && !string.Equals(authData, "null"));
        }
Beispiel #2
0
        public async Task <ProfileModel> GetProfile(int?profileId = null)
        {
            Task loggingTask = _logger.Info("Get Profile");

            return(await loggingTask.ContinueWith(async (task) =>
            {
                int id = 0;
                if (!profileId.HasValue || profileId == 0)
                {
                    var localStorageValues = await _interopService.GetLocalStorageItem("auth");
                    if (localStorageValues == null)
                    {
                        localStorageValues = "0";
                    }
                    id = int.Parse(localStorageValues);
                }
                else
                {
                    id = profileId.Value;
                }

                HttpResponseMessage response = await
                                               _httpClient.GetAsync($"{BaseUrl}/Profile/{id}");
                await _logger.Info(response.StatusCode.ToString());
                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    Stream responseStream = await response.Content.ReadAsStreamAsync();
                    ProfileModel result = await Utf8Json.JsonSerializer.DeserializeAsync <ProfileModel>(responseStream);
                    result.nextlevel = result.level + 1;
                    return result;
                }
                else
                {
                    throw new Exception("Get Profile failed");
                }
            }).Unwrap());
        }