Exemplo n.º 1
0
        public ActionResult Create(genreModel genre1)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.genres.Add(genre1);
                    db.SaveChanges();

                    return RedirectToAction("Index");
                }
                else
                {
                    return View();
                }

            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 2
0
 public ActionResult Edit(int id, genreModel genre2)
 {
     try
        {
        if (genre2 == null)
          {
              return HttpNotFound();
          }
         else if (ModelState.IsValid)
             {
                 db.Entry(genre2).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 return RedirectToAction("Index");
             }
        else
             {
                  return View();
             }
       }
       catch
       {
        return View();
       }
 }