public async Task <IActionResult> Delete(int id) { var mov = await _context.Movies.Where(x => x.Id == id).FirstOrDefaultAsync(); if (mov != null) { _context.Remove(mov); await _context.SaveChangesAsync(); return(Ok(mov)); } else { return(NotFound()); } }
public async Task <ActionResult <Movie> > Delete(int id) { try { Movie mov = await _context.Movies.SingleOrDefaultAsync(m => m.Id == id); if (mov != null) { _context.Remove(mov); await _context.SaveChangesAsync(); return(Ok(mov)); } else { return(NotFound("Record not found...")); } } catch (Exception e) { return(BadRequest("Exception..." + e.Message)); } }
public void Delete(Show show) { db.Remove(show); db.SaveChanges(); }