public static async Task <T> GetObjectFor <T>(HttpResponseMessage response)
        {
            if (response.IsSuccessStatusCode)
            {
                var serialized = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <T>(serialized));
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                var errorMessage = await GetErrorMessage(response);

                string displayMessage = GetDisplayMessage(errorMessage);
                if (!string.IsNullOrWhiteSpace(displayMessage))
                {
                    UserDialogsHelper.ShowNotification(displayMessage.ToString(), NotificationTypeEnum.Error, TimeSpan.FromSeconds(3));
                }
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
            {
                LogOut?.Invoke(httpResponsHelper, new EventArgs());
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.Forbidden)
            {
                UserDialogsHelper.ShowNotification("There was an error in processing your request.", NotificationTypeEnum.Error);
            }
            else if (!response.IsSuccessStatusCode)
            {
                UserDialogsHelper.ShowNotification("There was an error while fetching data.", NotificationTypeEnum.Error);
            }
            return(default(T));
        }
 private void ButtonLogOut_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Log out?", "Log out", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         LogOut?.Invoke(this, EventArgs.Empty);
     }
 }
Exemple #3
0
 public void Log(string msg, int i = -1, bool vital = true)
 {
     wr.WriteLine(msg);
     LogOut?.Invoke(msg, vital);
     if (i != -1)
     {
         string line = GenLine(i);
         wr.WriteLine(line);
         LogOut?.Invoke(line, vital);
     }
     wr.WriteLine("");
     LogOut?.Invoke("", vital);
 }
Exemple #4
0
        public async Task <NiconicoSignInStatus> SignOut()
        {
            NiconicoSignInStatus result = NiconicoSignInStatus.Failed;

            using (var releaser = await SigninLock.LockAsync())
            {
                UserId      = null;
                UserName    = null;
                UserIconUrl = null;

                IsLoggedIn = false;

                UpdateServiceStatus();

                if (Context == null)
                {
                    return(result);
                }

                try
                {
                    if (Helpers.InternetConnection.IsInternet())
                    {
                        result = await Context.SignOutOffAsync();
                    }
                    else
                    {
                        result = NiconicoSignInStatus.Success;
                    }

                    Context.Dispose();
                }
                finally
                {
                    Context = new NiconicoContext();

                    _UserId = null;
                }
            }

            LogOut?.Invoke(this, EventArgs.Empty);

            return(result);
        }
 private void executeLogOutCommand()
 {
     LogOut?.Invoke(this, new EventArgs());
 }
Exemple #6
0
 private void OnLogoutTapped()
 {
     LogOut?.Invoke();
     Present(_loginVC);
 }
Exemple #7
0
 private void OnLogOut(object input)
 {
     LogOut?.Invoke(this, EventArgs.Empty);
 }
Exemple #8
0
 private void UserSettingPage_LogOut(object sender, EventArgs e)
 {
     LogOut?.Invoke(this, EventArgs.Empty);
 }
Exemple #9
0
 private void buttonLogOut_Click(object sender, EventArgs e)
 {
     LogOut?.Invoke();
 }