예제 #1
0
        public void AddCrime(AddCrimeViewModel addCrimeViewModel)
        {
            Crime crime = new Crime();

            crime.Paragraph   = addCrimeViewModel.Paragraph;
            crime.Name        = addCrimeViewModel.Name;
            crime.Description = addCrimeViewModel.Description;

            databaseCrimes.InsertOne(crime);
        }
예제 #2
0
        private void AddCrime(object sender, RoutedEventArgs e)
        {
            AddCrimeViewModel addCrimeViewModel = new AddCrimeViewModel();

            try
            {
                addCrimeViewModel.Paragraph = Convert.ToInt32(ParagraphNumberTextBox.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Wpisana wartość nie jest liczbą. Wpisz liczbę, by uzyskać poprawny rezultat.", "Błąd!");
            }
            if (String.IsNullOrEmpty(CrimeNameTextBox.Text) || String.IsNullOrWhiteSpace(CrimeNameTextBox.Text))
            {
                MessageBox.Show("Nie wpisano tekstu. Wpisz tekst, by uzyskać poprawny rezultat.", "Błąd!");
            }
            else
            {
                addCrimeViewModel.Name = CrimeNameTextBox.Text;
            }
            if (String.IsNullOrEmpty(CrimeDescriptionTextBox.Text) || String.IsNullOrWhiteSpace(CrimeDescriptionTextBox.Text))
            {
                MessageBox.Show("Nie wpisano tekstu. Wpisz tekst, by uzyskać poprawny rezultat.", "Błąd!");
            }
            else
            {
                addCrimeViewModel.Description = CrimeDescriptionTextBox.Text;
            }

            Database database = Database.Instance;

            database.AddCrime(addCrimeViewModel);

            MessageBox.Show("Dodano nowy akt prawny do bazy", "Sukces!");

            this.NavigationService.Navigate(new MainPage());
        }