public void AddAlbum(Guid bandId, Album album) { if (bandId == null) { throw new ArgumentNullException(nameof(bandId)); } if (album == null) { throw new ArgumentNullException(nameof(album)); } album.BandId = bandId; _context.Add(album); }
public IActionResult AddBand([Bind("id,bandName,musicGenre")] BandModel newBand) { // if values passed in body of request meet validation annotations set in model if (ModelState.IsValid) { // add new band from body of request to data set _context.Add(newBand); // save changes to database (added record) _context.SaveChanges(); // retrun confirmation message return(Content($"Addd Band {newBand.bandName}")); } else // if values passed in body of request DOES NOT meet validation annotations set in model { // return errors from method return(Content(DisplayString(ModelState))); } }