private async void SignUpExecute(object o)
        {
            LoaderManager.Instance.ShowLoader();
            var result = await Task.Run(() =>
            {
                User currentUser;
                try
                {
                    // if (ApplicationStaticDB.GetUserByLogin(_login) != null)
                    if (GenericEntityWrapper.GetUserByName(_login) != null)
                    {
                        MessageBox.Show("Try up new name! This user already exists: " + _login);
                        return(false);
                    }
                    if (!IsValidEmail(_email))
                    {
                        MessageBox.Show("Invalid e-mail: " + _email);
                        return(false);
                    }
                    currentUser = new User(_name, _lastname, _email, _login, _password);
                    //ApplicationStaticDB.AddUser(currentUser);
                    try
                    {
                        GenericEntityWrapper.AddEntity <User>(currentUser);
                        MessageBox.Show("added");
                        SessionContext.CurrentUser = currentUser;
                        MessageBox.Show("currUser");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("" + e);
                    }
                    Logger.Log("User " + currentUser.Id + " signed up");
                    Serializer.Serialize(currentUser, StaticResources.StorageFilePath);
                    return(true);
                }
                catch (Exception ex)
                {
                    Logger.Log("Error , " + ex);
                    return(false);
                }
            });

            LoaderManager.Instance.HideLoader();
            if (result)
            {
                NavManager.Instance.Navigate(ModesEnum.Main);
            }
        }
Exemplo n.º 2
0
        public async void ReadFileExecute(object obj)
        {
            LoaderManager.Instance.ShowLoader();
            var result = await Task.Run(() =>
            {
                try
                {
                    OpenFile();
                }
                catch (Exception)
                {
                    return(false);
                }

                _currentQuery = new Query(DateTime.Now, FileName, FileText, SessionContext.CurrentUser.Id);
                Logger.Log("User " + SessionContext.CurrentUser.Id + " queried file " + FileName + "\n" + _currentQuery.WordCnt + " words, " + _currentQuery.LineCnt + " lines");
                MessageBox.Show(_currentQuery + "");
                return(true);
            });

            LoaderManager.Instance.HideLoader();
            if (result)
            {
                _queries.Add(_currentQuery); //local
                // _currentUser.AddQ(_currentQuery);//save for user


                try
                {
                    GenericEntityWrapper.AddEntity(_currentQuery);
                }
                catch (Exception e)
                {
                    Logger.Log("Error adding text query" + e);
                }
            }
        }
Exemplo n.º 3
0
 public void AddUser(User entity)
 {
     GenericEntityWrapper.AddEntity(entity);
 }
Exemplo n.º 4
0
 public void AddTextRequest(TextRequest entity)
 {
     GenericEntityWrapper.AddEntity(entity);
 }