public IHttpActionResult Edit(int Id, EditDvdRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } IDVDLibraryRepo myRepo = DVDRepoFactory.GetRepository(); DVD dvd = new DVD(); DVD current = myRepo.GetDvdById(Id); //if (dvd == null) //{ // return NotFound(); //} dvd.DVDId = Id; dvd.Title = request.Title; dvd.ReleaseYear = request.ReleaseYear; dvd.Rating = request.Rating; dvd.Director = request.Director; dvd.Notes = request.Notes; //add DVDId to current here???? myRepo.EditDvd(current, dvd); return(Ok(dvd)); }
public IHttpActionResult GetDvd(int dvdId) { IDVDLibraryRepo myRepo = DVDRepoFactory.GetRepository(); DVD selectedDvd = myRepo.GetDvdById(dvdId); if (selectedDvd == null) { return(NotFound()); } else { return(Ok(selectedDvd)); } }
public IHttpActionResult DeleteDvd(int dvdId) { IDVDLibraryRepo myRepo = DVDRepoFactory.GetRepository(); DVD dvd = myRepo.GetDvdById(dvdId); if (dvd == null) { return(NotFound()); } myRepo.DeleteDvd(dvdId); return(Ok()); }