예제 #1
0
 private void HandleSearchJobsCommand(object parameter)
 {
     if (this.SearchQuery != null || this.SearchQuery != "")
     {
         this.MatchedJobs = DataPersister.SearchJob(this.SearchQuery);
     }
 }
예제 #2
0
        private void HandleCreateListCommand(object parameter)
        {
            if (this.Title == null)
            {
                this.Message = "Title can not be null!";
                return;
            }

            if (this.Todos.Count == 0)
            {
                this.Message = "Todo list must contain at least one !";
                return;
            }
            var filledTodoes = this.Todos.Where(t => !string.IsNullOrEmpty(t.Text));

            if (filledTodoes.Count() == 0)
            {
                this.Message = "Todo list must contain at least one Todo!";
                return;
            }

            DataPersister.CreateNewTodosList(this.Title, filledTodoes);
            this.Title = "";
            this.Todos.Clear();
            this.TodoLists = DataPersister.GetTodoLists();
        }
        private void HandleRegisterCommand(object parameter)
        {
            var passwordBox = parameter as PasswordBox;
            var password    = passwordBox.Password;
            //SHA1 sha = new SHA1CryptoServiceProvider();
            //var passwordBytes = Encoding.Default.GetBytes(password);
            //passwordBytes = Encoding.Convert(Encoding.Default,Encoding.UTF8,passwordBytes);
            //var authenticationCodeBytes = sha.ComputeHash(passwordBytes);
            //var authenticationCode = Encoding.UTF8.GetString(authenticationCodeBytes);

            var authenticationCode = this.GetSHA1HashData(password);

            try
            {
                DataPersister.RegisterUser(this.Username, this.Email, authenticationCode);
                this.HandleLoginCommand(parameter);
            }
            catch (ArgumentException argEx)
            {
                this.Message = argEx.Message;
            }
            catch (Exception ex)
            {
                this.Message = ex.Message;
            }
        }
예제 #4
0
        private void HandleAddRehersalCommand(RehersalViewModel parameter)
        {
            parameter = DataPersister.GetBasicRehersal();
            int nameCounter = 1;

            parameter.Name = this.GetUniqueName(parameter.Name, nameCounter);
            this.rehersals.Insert(0, parameter);
        }
 private void HandleChangeUsernameCommand(object parameter)
 {
     if (DataPersister.ChangeSetting(this.NewUsername, null))
     {
         this.RaiseUsernameChangedSuccess(NewUsername);
         MessageBox.Show("Username changed successfuly!");
     }
 }
예제 #6
0
        public CurrencyDetailsPageViewModel()
        {
            this.CurrenciesDetailsPath = "..\\AppX\\ViewModels\\Files\\currencies.xml";
            IEnumerable <CurrencyDetailedViewModel> models =
                DataPersister.GetDetailedCurrencies(this.CurrenciesDetailsPath);

            this.CurrentModel = models.Where(x => x.Iso == Helper.Iso).FirstOrDefault();
        }
예제 #7
0
        /// <summary>
        /// Adds a collection of entities to the given persister.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="entities">The entities.</param>
        /// <typeparam name="TEntity">The entity type.</typeparam>
        public static void BulkAdd <TEntity>(this DataPersister query, IEnumerable <TEntity> entities) where TEntity : class, IEntity
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            query.BulkAdd(entities, item => item.IdentityValue);
        }
        public void CalculatePlayerScore()
        {
            int playerScore        = 0;
            int playerAnswersCount = this.playerAnswers.Count;

            for (int i = 0; i < playerAnswersCount; i++)
            {
                if (playerAnswers[i] != null)
                {
                    if (playerAnswers[i] == problems[i].Answer)
                    {
                        switch (this.Difficulty)
                        {
                        case Difficulty.Easy:
                            playerScore += 3;
                            break;

                        case Difficulty.Hard:
                            playerScore += 5;
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        switch (this.Difficulty)
                        {
                        case Difficulty.Easy:
                            playerScore -= 1;
                            break;

                        case Difficulty.Hard:
                            playerScore -= 3;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }

            if (timerIsRunning)
            {
                DataPersister.SavePlayerScore(playerScore);
                MessageBox.Show(string.Format("Your score is {0}.", playerScore));
                RaiseGameFinished();
            }

            this.timerIsRunning = false;
            StopTimer();
        }
예제 #9
0
        private void HandleLogoutCommand(object parameter)
        {
            bool isUserLoggedOut = DataPersister.LogoutUser();

            if (isUserLoggedOut)
            {
                this.Username     = "";
                this.LoggedInUser = false;
                this.HandleChangeViewModelCommand(this.LoginRegisterVM);
            }
        }
 private async void LoadNamesDaysAsync()
 {
     try
     {
         this.NamesDaysModels = await DataPersister.GetNamesDaysByMonth(this.CurrentMonth);
     }
     catch (WebException)
     {
         new MessageDialog("Няма връзка със сървъра.").ShowAsync();
     }
 }
        private void HandleChangePasswordCommand(object parameter)
        {
            var passwordBox        = parameter as PasswordBox;
            var password           = passwordBox.Password;
            var authenticationCode = this.GetSha1HashData(password);

            if (DataPersister.ChangeSetting(null, authenticationCode))
            {
                MessageBox.Show("Password changed successfuly!");
            }
        }
예제 #12
0
 private async void LoadResultsAsync()
 {
     try
     {
         this.Results = await DataPersister.GetName(this.QueryText.Replace('\u201c', '\0').Replace("\u201d", "\0"));
     }
     catch (WebException)
     {
         new MessageDialog("Няма връзка със сървъра.").ShowAsync();
     }
 }
예제 #13
0
        private void LoadResults()
        {
            var allNamesAndIso = DataPersister.GetCurrenciesNamesAndIso(this.currenciesDocumentPath);

            foreach (var item in allNamesAndIso)
            {
                if (item.Name.ToLower().Contains(this.QueryText.ToLower()))
                {
                    this.results.Add(item);
                }
            }
        }
예제 #14
0
        private void HandleCreateListCommand(object parameter)
        {
            DataPersister.CreateNewTodosList(this.Title, this.description, DateTime.Now,//this.deadline,
                                             this.price, this.category, this.totalDifficulty, this.TasksList.Where(t => !string.IsNullOrEmpty(t.Name)));
            this.Title           = "";
            this.Description     = "";
            this.Deadline        = "";
            this.price           = 0.0d;
            this.category        = "";
            this.totalDifficulty = "1";

            this.TasksList.Clear();
        }
예제 #15
0
        private void HandleLoginCommand(object parameter)
        {
            var passwordBox        = parameter as PasswordBox;
            var password           = passwordBox.Password;
            var authenticationCode = this.GetSHA1HashData(password);

            var username = DataPersister.LoginUser(this.Username, authenticationCode);

            if (!string.IsNullOrEmpty(username))
            {
                this.RaiseLoginSuccess(username);
            }
        }
예제 #16
0
        public IEntityData GetEntityData(bool generateIds = true)
        {
            var        store     = new DataStore();
            var        query     = new DataQuery(store);
            IPersister persister = new DataPersister(store);

            if (generateIds)
            {
                persister = new IdentityGeneratingPersisterDecorator(persister);
            }

            return(new EntityData(query, persister));
        }
        private void HandleRegisterCommand(object parameter)
        {
            var passwordBox        = parameter as PasswordBox;
            var password           = passwordBox.Password;
            var authenticationCode = this.GetSha1HashData(password);

            bool isRegistered = DataPersister.RegisterUser(this.Username, this.Email, authenticationCode);

            if (isRegistered)
            {
                this.HandleLoginCommand(parameter);
            }
        }
예제 #18
0
        private void ExecuteGoogleSearch()
        {
            var urls = DataPersister.GetImageUrls(this.GoogleImageSearch);

            if (urls.Any())
            {
                this.ImagesPath.Clear();
                foreach (var url in urls)
                {
                    this.ImagesPath.Add(url);
                }
            }
        }
            /// <summary>
            /// Use/Override the render function so that rendering takes place at the right time
            /// </summary>
            /// <param name="output"></param>
            protected override void Render(System.Web.UI.HtmlTextWriter output)
            {
                DataPersister persister = new DataPersister();
                IDbContext    dbcontext = persister.getDBContext();

                dbcontext.BeginTransaction();
                try
                {
                    output.Write(ParentControl.RenderToString(ControlDefnToRender, LangToRenderFor));
                    dbcontext.CommitTransaction();
                }
                catch
                {
                    dbcontext.RollbackTransaction();
                    throw;
                }
            }
        private void HandleRegisterCommand(object parameter)
        {
            var passwordBox = parameter as PasswordBox;
            var password    = passwordBox.Password;

            //TODO:SHA1
            #region TODO:SHA1
            //SHA1 sha = new SHA1CryptoServiceProvider();
            //var passwordBytes = Encoding.Default.GetBytes(password);
            //passwordBytes = Encoding.Convert(Encoding.Default,Encoding.UTF8,passwordBytes);
            //var authenticationCodeBytes = sha.ComputeHash(passwordBytes);
            //var authenticationCode = Encoding.UTF8.GetString(authenticationCodeBytes);
            #endregion

            var authenticationCode = this.GetSHA1HashData(password);

            DataPersister.RegisterUser(this.RegUsername, this.DisplayName, this.Email, this.Phone, this.Location, authenticationCode);
            this.HandleLoginRegisterCommand(parameter);
        }
예제 #21
0
파일: TestSetUp.cs 프로젝트: Quadre/tut.by
 public void SetUp()
 {           
     DataPersister<GeneralConfig> cfgHelper = new DataPersister<GeneralConfig>();
                 
     if (cfgHelper.FileExist(GeneralConfig.DEFAULT_FILE_NAME))
     {
         Config =  cfgHelper.Load(GeneralConfig.DEFAULT_FILE_NAME);
     }
     else
     {
         Config = GeneralConfig.CreateDefault();
         cfgHelper.Save(Config, GeneralConfig.DEFAULT_FILE_NAME);
     }
     
     // think about muti-browser support
     WebDriver = new ChromeDriver();
     
     // configure default timeouts
     WebDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(Config.DefaultTimeoutSec));
 }
예제 #22
0
        private void HandleRegisterCommand(object parameter)
        {
            var passwordBox = parameter as PasswordBox;
            var password    = passwordBox.Password;

            var authenticationCode = this.GetSHA1HashData(password);

            try
            {
                DataPersister.RegisterUser(this.Username, this.Email, authenticationCode);
                this.HandleLoginCommand(parameter);
            }
            catch (ArgumentException argEx)
            {
                this.Message = argEx.Message;
            }
            catch (Exception ex)
            {
                this.Message = ex.Message;
            }
        }
예제 #23
0
        private void HandleLoginCommand(object parameter)
        {
            var passwordBox        = parameter as PasswordBox;
            var password           = passwordBox.Password;
            var authenticationCode = this.GetSHA1HashData(password);

            try
            {
                var username = DataPersister.LoginUser(this.Username, authenticationCode);

                if (!string.IsNullOrEmpty(username))
                {
                    this.RaiseLoginSuccess(username);
                }
            }
            catch (ArgumentException argEx)
            {
                this.Message = argEx.Message;
            }
            catch (Exception ex)
            {
                this.Message = ex.Message;
            }
        }
예제 #24
0
 private void HandleChangeStateCommand(object parameter)
 {
     DataPersister.ChangeState(this.Id);
 }
예제 #25
0
 public void SetUp() 
 {            
     dataHelper = new DataPersister<RateData>();
     financePage = new FinancePage(TestSetup.WebDriver, TestSetup.Config);
     financePage.Navigate();
 }       
예제 #26
0
 private void ChangeMoviesDetail()
 {
     this.MovieDetail = DataPersister.GetDetails(this.SelectedMovie.Id);
 }
예제 #27
0
 public void ChangeMovies()
 {
     this.MoviesInSelectedCinema = DataPersister.GetMoviesForCinema(this.SelectCinema.Id);
 }
예제 #28
0
 public void ChangeProjectionDetailsForMovie()
 {
     this.ProjectionsDetails = DataPersister.GetMoviesProjectionsDetails(this.SelectCinema.Id,
                                                                         this.SelectedMovie.Id, this.SelectedProjection.Id);
 }
예제 #29
0
 private void HandleReservationCallCommand(object parameter)
 {
     this.Code = DataPersister.ReserveCall(this.Seats, this.Email, this.SelectedProjection.Id);
 }
예제 #30
0
 private void HandleRemoveCommand(object parameter)
 {
     DataPersister.RemoveCommand(this.Email, this.Code, this.SelectedProjection.Id);
 }
예제 #31
0
 private async void HandleGetDataAsync()
 {
     this.Rehersals = await DataPersister.GetRehersalsDataAsync();
 }