public async Task <IActionResult> Create([Bind("PersonID,CDSID,Name,SurName,Lended")] CDLended cDLended) { if (ModelState.IsValid) { var linq = _context.CD.SingleOrDefault(x => x.CDID == cDLended.CDSID); cDLended.CDs = linq; _context.Add(cDLended); linq.Lended = true; _context.Update(linq); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cDLended)); }
public async Task <IActionResult> Edit(int id, [Bind("ArtistID,ArtistName")] Artist artist) { if (id != artist.ArtistID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(artist); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArtistExists(artist.ArtistID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(artist)); }
public async Task <IActionResult> Edit(int id, [Bind("CDID ,Album,Genre,ArtistNameID,Lended")] CD cD) { if (id != cD.CDID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cD); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CDExists(cD.CDID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cD)); }