private void Add_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(Name.Text)) { var genre = new Genre() { Name = Name.Text }; genreDAO.Add(genre); } }
public ActionResult Validate(Genre genre) { try { if (ModelState.IsValid) { GenreDAO dao = new GenreDAO(); if (dao.IsUnique(genre)) { dao.Add(genre); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); } ViewBag.Genre = genre; return(View("Index")); } catch { return(RedirectToAction("Index", "Home")); } }