public ActionResult Tracks(int id, [Bind(Include = "TrackId,TrackSequence")] Track_Album t_a) { t_a.AlbumId = id; T_aDB.Add(t_a); return(RedirectToAction("Tracks", new { id = t_a.AlbumId })); }
public ActionResult RemoveTrackLink(int id) { Track_Album t_a = T_aDB.Find(id); T_aDB.Delete(t_a); return(RedirectToAction("Tracks", new { id = t_a.AlbumId })); }
public ActionResult EditTrack([Bind(Include = "Id,TrackSequence,TrackId,AlbumId")] Track_Album t_a) { if (ModelState.IsValid) { T_aDB.Update(t_a); return(RedirectToAction("Tracks", new { id = t_a.AlbumId })); } return(View(t_a)); }
//POST //Save in album public async Task <IActionResult> InAlbum(Guid albumId, Guid trackId, Track_Album track_Album) { track_Album.Track_AlbumId = Guid.NewGuid(); //var nowAlbumId= (Guid)TempData["AlbumId"]; track_Album.AlbumId = albumId; //track_Album.AlbumId = ViewBag.albumId; track_Album.TrackId = trackId; var album = _context.Albums.FirstOrDefault(a => a.AlbumId == albumId); var track = _context.Tracks.FirstOrDefault(t => t.TrackID == trackId); track_Album.Album = album; track_Album.Track = track; _context.Add(track_Album); await _context.SaveChangesAsync(); return(RedirectToAction("GetTracks")); }
// GET: Album/EditTrack/5 public ActionResult EditTrack(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Track_Album t_a = T_aDB.Find(id); if (t_a == null) { return(HttpNotFound()); } List <SelectListItem> selectList = getSelectlistAvailableTracksInAlbum(t_a.AlbumId); selectList.Add(new SelectListItem() { Text = t_a.Track.name + " (current)", Value = t_a.TrackId.ToString() }); ViewBag.TrackAlbumSelectList = selectList; return(View(t_a)); }