public IHttpActionResult Update(UpdateDvdRequest request) { var repo = DvdRepositoryFactory.Create(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Dvd dvd = repo.GetDvd(request.DvdId); if (dvd == null) { return(NotFound()); } dvd.Title = request.Title; dvd.Director = request.Director; dvd.ReleaseYear = request.ReleaseYear; dvd.Rating = request.Rating; dvd.Notes = request.Notes; repo.EditDvd(dvd); return(Ok(dvd)); }
public IHttpActionResult DeleteDvd(int DvdId) { Dvd dvd = DvdRepositoryFactory.Create().GetDvdByID(DvdId); if (dvd == null) { return(NotFound()); } DvdRepositoryFactory.Create().DeleteDvd(DvdId); return(Ok()); }
public IHttpActionResult GetAllDvds() { List <Dvd> dvds = DvdRepositoryFactory.Create().GetAllDvds(); if (dvds == null) { return(NotFound()); } else { return(Ok(dvds)); } }
public IHttpActionResult GetDvdByTitle(string title) { List <Dvd> dvds = DvdRepositoryFactory.Create().GetDvdByTitle(title); if (dvds == null) { return(NotFound()); } else { return(Ok(dvds)); } }
public IHttpActionResult GetDvdByReleaseYear(int releaseYear) { List <Dvd> dvds = DvdRepositoryFactory.Create().GetDvdByReleaseYear(releaseYear); if (dvds == null) { return(NotFound()); } else { return(Ok(dvds)); } }
public void EditDvd(int id, Dvd dvd) { //validate edit if (ModelState.IsValid) { IDvdRepository DvdRepo = DvdRepositoryFactory.Create(); DvdRepo.Edit(dvd); } else { Content(HttpStatusCode.BadRequest, "Model state invalid"); } }
public IHttpActionResult Delete(int id) { var repo = DvdRepositoryFactory.Create(); Dvd movie = repo.GetDvd(id); if (movie == null) { return(NotFound()); } repo.DeleteDvd(id); return(Ok()); }
public IHttpActionResult GetDvdByDirector(string director) { List <Dvd> dvds = DvdRepositoryFactory.Create().GetDvdByDirector(director); if (dvds == null) { return(NotFound()); } else { return(Ok(dvds)); } }
public IHttpActionResult Get(int id) { var repo = DvdRepositoryFactory.Create(); Dvd dvd = repo.GetDvd(id); if (dvd == null) { return(NotFound()); } else { return(Ok(dvd)); } }
public IHttpActionResult GetDvdById(int DvdId) { Dvd dvd = DvdRepositoryFactory.Create().GetDvdByID(DvdId); if (dvd == null) { return(NotFound()); } else { //Creates HTTP Response status 200 return(Ok(dvd)); } }
public IHttpActionResult GetDvdsByDate(int year) { var repo = DvdRepositoryFactory.Create(); List <Dvd> dvds = repo.GetDvdsByDate(year); if (dvds == null) { return(NotFound()); } else { return(Ok(dvds)); } }
public IHttpActionResult GetDvdsByRating(string rating) { var repo = DvdRepositoryFactory.Create(); List <Dvd> dvds = repo.GetDvdsByRating(rating); if (dvds == null) { return(NotFound()); } else { return(Ok(dvds)); } }
public void CreateDvd(AddDvdRequest request) { IDvdRepository repo = DvdRepositoryFactory.Create(); Dvd dvd = new Dvd { Title = request.Title, RealeaseYear = request.RealeaseYear, Director = request.Director, Rating = request.Rating, Notes = request.Notes }; repo.AddDvd(dvd); }
public IHttpActionResult AddDvd(Dvd dvd) { //validate add if (ModelState.IsValid) { IDvdRepository DvdRepo = DvdRepositoryFactory.Create(); DvdRepo.Add(dvd); //return route return(Created($"/dvd{dvd.DvdId}", dvd)); } else { return(Content(HttpStatusCode.BadRequest, "Model state invalid")); } }
public void UpdateDvd(int id, EditDvdRequest request) { IDvdRepository repo = DvdRepositoryFactory.Create(); Dvd dvd = new Dvd { DvdId = request.DvdId, Title = request.Title, RealeaseYear = request.RealeaseYear, Director = request.Director, Rating = request.Rating, Notes = request.Notes }; repo.EditDvd(dvd, id); }
public IHttpActionResult CreateDvd(Dvd info) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Dvd newDvd = new Dvd() { Title = info.Title, ReleaseYear = info.ReleaseYear, Director = info.Director, Rating = info.Rating, Notes = info.Notes }; DvdRepositoryFactory.Create().CreateDvd(info); return(Created($"dvd/{info.DvdId}", info)); }
public IHttpActionResult Add(AddDvdRequest request) { var repo = DvdRepositoryFactory.Create(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Dvd dvd = new Dvd() { Title = request.Title, Director = request.Director, ReleaseYear = request.ReleaseYear, Rating = request.Rating, Notes = request.Notes }; repo.AddDvd(dvd); return(Created($"dvd/get/{dvd.DvdId}", dvd)); }
public IHttpActionResult UpdateDvd(Dvd info) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Dvd dvd = DvdRepositoryFactory.Create().GetDvdByID(info.DvdId); if (dvd == null) { return(NotFound()); } dvd.DvdId = info.DvdId; dvd.Title = info.Title; dvd.ReleaseYear = info.ReleaseYear; dvd.Director = info.Director; dvd.Rating = info.Rating; dvd.Notes = info.Notes; DvdRepositoryFactory.Create().UpdateDvd(dvd); return(Ok(dvd)); }
public List <Dvd> GetByRating(string rating) { IDvdRepository repo = DvdRepositoryFactory.Create(); return(repo.GetByRating(rating)); }
public List <Dvd> GetByDirector(string directorName) { IDvdRepository repo = DvdRepositoryFactory.Create(); return(repo.GetByDirector(directorName)); }
public List <Dvd> GetByRealeaseYear(int realeaseYear) { IDvdRepository repo = DvdRepositoryFactory.Create(); return(repo.GetByYear(realeaseYear)); }
public List <Dvd> GetByTitle(string title) { IDvdRepository repo = DvdRepositoryFactory.Create(); return(repo.GetByTitle(title)); }
public List <Dvd> GetAll() { IDvdRepository repo = DvdRepositoryFactory.Create(); return(repo.GetAll()); }
public Dvd GetById(int id) { IDvdRepository repo = DvdRepositoryFactory.Create(); return(repo.GetById(id)); }
public IHttpActionResult GetByTitle(string title) { IDvdRepository DvdRepo = DvdRepositoryFactory.Create(); return(Ok(DvdRepo.GetByTitle(title))); }
public IHttpActionResult GetByReleaseYear(int releaseYear) { IDvdRepository DvdRepo = DvdRepositoryFactory.Create(); return(Ok(DvdRepo.GetByReleaseYear(releaseYear))); }
public IHttpActionResult GetByDirectorName(string directorName) { IDvdRepository DvdRepo = DvdRepositoryFactory.Create(); return(Ok(DvdRepo.GetByDirector(directorName))); }
public IHttpActionResult GetByRating(string rating) { IDvdRepository DvdRepo = DvdRepositoryFactory.Create(); return(Ok(DvdRepo.GetByRating(rating))); }
static DvdController() { _repo = DvdRepositoryFactory.Create(); }
public void DeleteDvd(int id) { IDvdRepository repo = DvdRepositoryFactory.Create(); repo.DeleteDvd(id); }