Example #1
0
        public IHttpActionResult GetMovieShowings(MovieNameDTO movie) // GETS MOVIESHOWINGS
        {
            MoviesManager mmgr    = new MoviesManager();
            int           movieId = mmgr.GetMovieIdFromName(movie.MovieName);

            if (movieId == 0)
            {
                TextResult failedToFindMovieShowing = new TextResult("Movieshowing does not exist!", msg);
                return(failedToFindMovieShowing);
            }
            var movieList = mmgr.GetMovieShowingsFromMovieId(movieId); // Gets movieshowingtimes and puts in list

            return(Ok(movieList));
        }
Example #2
0
        public IHttpActionResult DeleteMovieShowings(MovieNameDTO movie)
        {
            TextResult    httpResponse = new TextResult("Could not delete movieshowing!", msg);
            MoviesManager mmgr         = new MoviesManager();
            int           movieId      = mmgr.GetMovieIdFromName(movie.MovieName);

            if (movieId == 0)
            {
                return(NotFound());
            }
            try
            {
                db.MovieShowings.RemoveRange(db.MovieShowings.Where(x => x.movieId == movieId));
                db.SaveChanges();
            } catch
            {
                return(httpResponse);
            }


            return(Ok());
        }
Example #3
0
        public IHttpActionResult DeleteMovies(MovieNameDTO movie) // Deletes movie from db and any related movieshowings
        {
            MoviesManager mmgr        = new MoviesManager();
            int           movieId     = mmgr.CheckIfMovieExists(movie.MovieName);
            Movies        movieEntity = db.Movies.Find(movieId);

            if (movieEntity is null)
            {
                return(NotFound());
            }
            try
            {
                db.MovieShowings.RemoveRange(db.MovieShowings.Where(x => x.movieId == movieId));
                db.Movies.Remove(movieEntity);
                db.SaveChanges();
            } catch
            {
                return(Ok());
            }
            TextResult couldNotDeleteMovieAndShowings = new TextResult("Could not delete movie!", msg);

            return(couldNotDeleteMovieAndShowings);
        }