Exemplo n.º 1
0
 public IActionResult Add(Genre genre)
 {
     if (ModelState.IsValid)
     {
         _genreRepo.AddGenre(genre);
         return(RedirectToAction("Table", genre));
     }
     else
     {
         return(View("AddForm"));
     }
 }
Exemplo n.º 2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (descriptionTextBox.Text == "")
     {
         descriptionTextBox.Text = "-";
     }
     if (EmptyChecker.TryTextFieldsEmpty(Controls))
     {
         MessageBox.Show("Please make sure you enter a value for all text fields", "Value empty error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     TextBoxParser.TextBoxChecker(Controls);
     if (!_genreRepo.AddGenre(genreTextBox.Text, descriptionTextBox.Text))
     {
         MessageBox.Show("There's already a genre called like this", "Genre exists error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         return;
     }
     genreTextBox.Text       = "";
     descriptionTextBox.Text = "";
 }