private async void SignInExecute(object obj)
        {
            LoaderManager.Instance.ShowLoader();
            var result = await Task.Run(() =>
            {
                User currentUser;
                try
                {
                    // currentUser = DB.ApplicationStaticDB.GetUserByLogin(_login);
                    currentUser = DB.GenericEntityWrapper.GetUserByName(_login);
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show("Login Error :" + ex);
                    Logger.Log("Error getting user" + ex);
                    return(false);
                }
                if (currentUser == null)
                {
                    System.Windows.MessageBox.Show(_login + " - no such users!Error!");
                    return(false);
                }
                try
                {
                    if (!currentUser.CheckPassword(_password))
                    {
                        System.Windows.MessageBox.Show("Error!Wrong password!");
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show("Error!" + ex);
                    Logger.Log("Error for user, " + ex);
                    return(false);
                }
                try
                {
                    SessionContext.CurrentUser = currentUser;
                    currentUser.LastLoginDate  = DateTime.Now;
                    GenericEntityWrapper.EditEntity(currentUser);
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show("Login Error :" + e);
                    Logger.Log($"Error updating user {SessionContext.CurrentUser}" + e);
                    return(false);
                }
                //SessionContext.CurrentUser = currentUser;
                Logger.Log("User " + currentUser.Id + " signed in");
                return(true);
            });

            LoaderManager.Instance.HideLoader();
            if (result)
            {
                // MessageBox.Show("App started"+ ModesEnum.Main);
                NavManager.Instance.Navigate(ModesEnum.Main);
            }
        }
Exemplo n.º 2
0
 public void EditTextRequest(TextRequest entity)
 {
     GenericEntityWrapper.EditEntity(entity);
 }
Exemplo n.º 3
0
 public void EditUser(User entity)
 {
     GenericEntityWrapper.EditEntity(entity);
 }