コード例 #1
0
        public ActionResult Create(Song song)
        {
            if (ModelState.IsValid)
            {
                song.Id = Guid.NewGuid();
                db.Songs.Add(song);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(song);
        }
コード例 #2
0
 public ActionResult Edit(Song song)
 {
     if (ModelState.IsValid)
     {
         db.Entry(song).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(song);
 }