Exemple #1
0
        public IHttpActionResult CreateNewDvd(Dvd dvd)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            repo.Insert(dvd);
            return(Ok(dvd.DvdId));
        }
Exemple #2
0
        public IHttpActionResult GetDvdById(int id)
        {
            var repo = DvdRepositoryFactory.GetRepository();
            var dvds = repo.GetById(id);

            return(Ok(dvds));
        }
Exemple #3
0
        public IHttpActionResult Index()
        {
            var repo = DvdRepositoryFactory.GetRepository();
            var dvds = repo.GetAllDvd();

            return(Ok(dvds));
        }
Exemple #4
0
        public IHttpActionResult GetByReleaseYear(int releaseYear)
        {
            var repo = DvdRepositoryFactory.GetRepository();
            var dvds = repo.GetByYear(releaseYear);

            return(Ok(dvds));
        }
Exemple #5
0
        public IHttpActionResult GetDvdsByTitle(string title)
        {
            var repo = DvdRepositoryFactory.GetRepository();
            var dvds = repo.GetByTitle(title);

            return(Ok(dvds));
        }
Exemple #6
0
        public IHttpActionResult GetByDirector(string directorName)
        {
            var repo = DvdRepositoryFactory.GetRepository();
            var dvds = repo.GetByDirector(directorName);

            return(Ok(dvds));
        }
Exemple #7
0
        public IHttpActionResult GetByRating(string rating)
        {
            var repo = DvdRepositoryFactory.GetRepository();
            var dvds = repo.GetByRating(rating);

            return(Ok(dvds));
        }
Exemple #8
0
        public IHttpActionResult DeleteById(int dvdId)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            repo.Delete(dvdId);
            return(Ok());
        }
        // GET: Dvd
        public ActionResult Details(int id)
        {
            var repo  = DvdRepositoryFactory.GetRepository();
            var model = repo.GetById(id);

            return(View(model));
        }
Exemple #10
0
        public IHttpActionResult UpdateById(Dvd dvd)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            repo.Update(dvd);
            return(Ok(dvd.DvdId));
        }
Exemple #11
0
        public IHttpActionResult UpdateDvd(GetDvds dvd)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            repo.Edit(dvd.DvdId, dvd.Title, dvd.ReleaseYear, dvd.Director, dvd.Rating, dvd.Notes);

            return(Ok());
        }
Exemple #12
0
        public IHttpActionResult NewDvd(GetDvds dvd)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            repo.SaveNew(dvd.Title, dvd.ReleaseYear, dvd.Director, dvd.Rating, dvd.Notes);

            return(Ok());
        }
Exemple #13
0
        public IHttpActionResult Delete(int dvdID)
        {
            DVDdb dvd = DvdRepositoryFactory.GetRepository().Get(dvdID);

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

            DvdRepositoryFactory.GetRepository().Delete(dvdID);
            return(Ok());
        }
Exemple #14
0
        public IHttpActionResult Get(int dvdID)
        {
            DVDdb dvd = DvdRepositoryFactory.GetRepository().Get(dvdID);

            if (dvd == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(dvd));
            }
        }
        public IHttpActionResult DvdDetails(int dvdID)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            try
            {
                var result = repo.GetByID(dvdID);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult LoadDvds()
        {
            var repo = DvdRepositoryFactory.GetRepository();

            try
            {
                var result = repo.GetAll();
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult SearchByCategory(string Category, string SearchTerm)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            try
            {
                var result = repo.SearchByCategory(Category, SearchTerm);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult GetByReleaseDate(DateTime date)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            try
            {
                var result = repo.GetByReleaseDate(date);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public ActionResult Add(DvdShortItem model)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            try
            {
                repo.Insert(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(View(model));
        }
        public IHttpActionResult GetByDirector(string directorName)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            try
            {
                var result = repo.GetByDirector(directorName);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult Add(Dvd dvd)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            try
            {
                repo.Add(dvd);
                System.Web.Http.Results.OkResult okResult = Ok();
                return(okResult);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult Remove(int dvdID)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            try
            {
                repo.Delete(dvdID);
                return(Ok());
                //System.Web.Http.Results.OkResult okResult = Ok();
                //return okResult;
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult Update(Dvd dvd)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            try
            {
                repo.Edit(dvd);
                return(Ok());
                //System.Web.Http.Results.OkResult okResult = Ok();
                //return okResult;
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #24
0
        public IHttpActionResult Add(AddDvdRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            DVDdb dvd = new DVDdb()
            {
                title        = request.title,
                realeaseYear = request.realeaseYear,
                director     = request.director,
                rating       = request.rating,
                notes        = request.notes //Not Required
            };

            DvdRepositoryFactory.GetRepository().Add(dvd);
            return(Created($"dvds/get/{dvd.dvdId}", dvd));
        }
Exemple #25
0
        public IHttpActionResult Update(UpdateDvdRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            DVDdb dvd = DvdRepositoryFactory.GetRepository().Get(request.dvdID);

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

            dvd.title        = request.title;
            dvd.realeaseYear = request.realeaseYear;
            dvd.director     = request.director;
            dvd.rating       = request.rating;
            dvd.notes        = request.notes; //Not Required

            DvdRepositoryFactory.GetRepository().Edit(dvd, dvd.dvdId);
            return(Ok(dvd));
        }
Exemple #26
0
        public IHttpActionResult GetAllDvds()
        {
            var repo = DvdRepositoryFactory.GetRepository();

            return(Ok(repo.GetAll()));
        }
Exemple #27
0
        public IHttpActionResult SearchDvds(string category, string searchTerm)
        {
            var repo = DvdRepositoryFactory.GetRepository();

            return(Ok(repo.GetBySearch(category, searchTerm)));
        }
Exemple #28
0
 public IHttpActionResult AllByDirector(string director)
 {
     return(Ok(DvdRepositoryFactory.GetRepository().GetAll().Where(kvp => kvp.Value.director.ToUpper().Contains(director.ToUpper())).Select(kvp => kvp.Value).ToList()));
 }
Exemple #29
0
 public IHttpActionResult AllByRating(string rating)
 {
     return(Ok(DvdRepositoryFactory.GetRepository().GetAll().Where(kvp => kvp.Value.rating.ToUpper().Contains(rating.ToUpper())).Select(kvp => kvp.Value).ToList()));
 }
        public ActionResult Index()
        {
            var repo = DvdRepositoryFactory.GetRepository();

            return(View(repo.GetAll()));
        }