public IActionResult AddArtist(ArtistPostIndexModel model) { if (model == null) { RedirectToAction("ArtistInfo", new { id = model.Artist.Id }); } var artistModel = model.Artist; var genreModel = model.Genres; //add the artist - populate an Artist instance with values from the form var artist = new Artist { Id = artistModel.Id, //is 0 here ArtistName = artistModel.ArtistName, Bio = artistModel.Bio, YrFormed = artistModel.YrFormed, YrEnded = artistModel.YrEnded, HomeCountry = artistModel.HomeCountry, HomeTown = artistModel.HomeTown, isActive = artistModel.isActive }; _artist.Add(artist); //now add the genre list ... var genres = genreModel.Select (g => new GenreListingModel { Id = g.Id, Name = g.Name, isMarked = g.isMarked } ).ToList(); //... so loop through returned genres model to update table... foreach (var g in genres) { if (g.isMarked) { _artistGenre.Add(g.Id, artist.Id); } ; } //should go back to details page ... ArtistMod?? //temp!!! redirect to main page return(RedirectToAction("Index", "Main", new { genreId = 1, artistId = model.Artist.Id })); }