예제 #1
0
        public ActionResult Create([Bind(Include = "Id,Title,TotalTracks,ReleaseDate,BandId")] Album album)
        {
            if (ModelState.IsValid)
            {
                db.Albums.Add(album);
                db.SaveChanges();
                return(RedirectToAction("Albums", "Band", new { id = album.BandId }));
            }

            return(View(album));
        }
예제 #2
0
        public bool SaveChanges()
        {
            //SaveChanges() returns the number of records that were saved.
            //If it returns 0, it means 0 records were saved, which means the save was successful but
            //there were no records to save. -1 shows that the saving was unsuccessful.

            if (_db.SaveChanges() < 0)
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
 public bool Save()
 {
     return(_context.SaveChanges() >= 0);
 }
예제 #4
0
 public ActionResult Create(Band band)
 {
     db.Bands.Add(band);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
예제 #5
0
 public ActionResult Create(Track track)
 {
     db.Tracks.Add(track);
     db.SaveChanges();
     return(RedirectToAction("Tracks", "Band", new { id = track.AlbumId }));
 }