Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetDvd(int dvdId)
        {
            IDVDLibraryRepo myRepo      = DVDRepoFactory.GetRepository();
            DVD             selectedDvd = myRepo.GetDvdById(dvdId);

            if (selectedDvd == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(selectedDvd));
            }
        }
Exemplo n.º 3
0
        public IHttpActionResult DeleteDvd(int dvdId)
        {
            IDVDLibraryRepo myRepo = DVDRepoFactory.GetRepository();

            DVD dvd = myRepo.GetDvdById(dvdId);

            if (dvd == null)
            {
                return(NotFound());
            }

            myRepo.DeleteDvd(dvdId);
            return(Ok());
        }