コード例 #1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(Name.Text))
            {
                var genre = new Genre()
                {
                    Name = Name.Text
                };

                genreDAO.Add(genre);
            }
        }
コード例 #2
0
 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"));
     }
 }