Ejemplo n.º 1
0
        public async Task <IActionResult> AddMovie(MovieCreateRequestModel request)
        {
            var movie = await _movieService.CreateMovie(request);

            //routename, routeid,object
            return(CreatedAtRoute("GetMovieById", new { id = movie.Id }, movie));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateMovieAsync(MovieCreateRequestModel movieCreateRequestModel)
        {
            //take info from view and save it to DB
            var createdMovie = await _movieService.CreateMovie(movieCreateRequestModel);

            return(View());
        }
Ejemplo n.º 3
0
        public async Task <MovieDetailResponseModel> UpdateMovie(MovieCreateRequestModel request)
        {
            var updatedMovie = await _movieRepository.UpdateAsync(new Movie { Id = request.Id, Title = request.Title, Budget = request.Budget, Revenue = request.Revenue });

            return(new MovieDetailResponseModel {
                Id = updatedMovie.Id, Title = updatedMovie.Title, Budget = updatedMovie.Budget, Revenue = updatedMovie.Revenue
            });
        }
Ejemplo n.º 4
0
        public IActionResult CreateMovie(MovieCreateRequestModel movieCreateRequestModel)
        {
            // Note: modalbyname is case insensitive

            // take the information from View and Save it to Database
            // save to database
            return(View());
        }
Ejemplo n.º 5
0
 public async Task <IActionResult> AddMovie(MovieCreateRequestModel model)
 {
     if (ModelState.IsValid)
     {
         //send the model to our service
         await _movieService.CreateMovie(model);
     }
     return(View());
 }
Ejemplo n.º 6
0
        public async Task <MovieDetailsResponseModel> UpdateMovie(MovieCreateRequestModel movieCreateRequestModel)
        {
            var movie = new Movie()
            {
                Id               = movieCreateRequestModel.Id,
                Title            = movieCreateRequestModel.Title,
                Overview         = movieCreateRequestModel.Overview,
                Tagline          = movieCreateRequestModel.Tagline,
                Revenue          = movieCreateRequestModel.Revenue,
                Budget           = movieCreateRequestModel.Budget,
                ImdbUrl          = movieCreateRequestModel.ImdbUrl,
                TmdbUrl          = movieCreateRequestModel.TmdbUrl,
                PosterUrl        = movieCreateRequestModel.PosterUrl,
                BackdropUrl      = movieCreateRequestModel.BackdropUrl,
                OriginalLanguage = movieCreateRequestModel.OriginalLanguage,
                ReleaseDate      = movieCreateRequestModel.ReleaseDate,
                RunTime          = movieCreateRequestModel.RunTime,
                Price            = movieCreateRequestModel.Price,
                Genres           = new List <Genre>()
            };

            foreach (var genre in movieCreateRequestModel.Genres)
            {
                movie.Genres.Add(new Genre()
                {
                    Id   = genre.Id,
                    Name = genre.Name,
                });
            }

            var newMovie = await _movieRepository.UpdateAsync(movie);

            var moiveResponse = new MovieDetailsResponseModel()
            {
                Id          = newMovie.Id,
                Title       = newMovie.Title,
                Budget      = newMovie.Budget,
                PosterUrl   = newMovie.PosterUrl,
                Rating      = newMovie.Rating,
                ReleaseDate = newMovie.ReleaseDate,
                BackdropUrl = newMovie.BackdropUrl,
                ImdbUrl     = newMovie.ImdbUrl,
                Tagline     = newMovie.Tagline,
                Price       = newMovie.Price,
                Revenue     = newMovie.Revenue,
                RunTime     = newMovie.RunTime,
                Overview    = newMovie.Overview,
                TmdbUrl     = newMovie.TmdbUrl,
            };

            return(moiveResponse);
        }
Ejemplo n.º 7
0
        public async Task <MovieDetailsResponseModel> UpdateMovie(MovieCreateRequestModel model)
        {
            var movie = new Movie
            {
                Title            = model.Title,
                Overview         = model.Overview,
                Tagline          = model.Tagline,
                Revenue          = model.Revenue,
                Budget           = model.Budget,
                ImdbUrl          = model.ImdbUrl,
                TmdbUrl          = model.TmdbUrl,
                PosterUrl        = model.PosterUrl,
                BackdropUrl      = model.BackdropUrl,
                OriginalLanguage = model.OriginalLanguage,
                ReleaseDate      = model.ReleaseDate,
                RunTime          = model.RunTime,
                Price            = model.Price,
            };
            var movieGenres = new List <Genre>();

            foreach (var genre in model.Genres)
            {
                movieGenres.Add(new Genre
                {
                    Id   = genre.Id,
                    Name = genre.Name,
                });
            }
            movie.Genres = movieGenres;

            var updatedMovie = await _movieRepository.Update(movie);

            var response = new MovieDetailsResponseModel
            {
                Id          = updatedMovie.Id,
                Title       = updatedMovie.Title,
                Overview    = updatedMovie.Overview,
                Tagline     = updatedMovie.Tagline,
                Revenue     = updatedMovie.Revenue,
                Budget      = updatedMovie.Budget,
                ImdbUrl     = updatedMovie.ImdbUrl,
                TmdbUrl     = updatedMovie.TmdbUrl,
                PosterUrl   = updatedMovie.PosterUrl,
                BackdropUrl = updatedMovie.BackdropUrl,
                ReleaseDate = updatedMovie.ReleaseDate,
                RunTime     = updatedMovie.RunTime,
                Price       = updatedMovie.Price,
                //Genres = updatedMovie.Genres,
            };

            return(response);
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> CreateMovie(MovieCreateRequestModel model)
        {
            //check for model validation on server also
            if (ModelState.IsValid)
            {
                // save to database
                var movie = await _movieService.CreateMovie(model);

                // redirect to new created movie
                return(LocalRedirect(localUrl: $"~/Movies/Details/{movie.Id}"));
            }
            return(View());
        }
Ejemplo n.º 9
0
        public async Task <MovieDetailsResponseModel> UpdateMovie(MovieCreateRequestModel movieCreateRequest)
        {
            //find the movie
            var movie = new Movie();

            PropertyCopy.Copy(movie, movieCreateRequest);
            var updateResult = await _repo.UpdateAsync(movie);

            var movieResult = new MovieDetailsResponseModel();

            PropertyCopy.Copy(movieResult, updateResult);

            return(movieResult);
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> UpdateMovieByAdminAsync(MovieCreateRequestModel model)
        {
            if (ModelState.IsValid)
            {
                //send the model to our service
                var response = await _movieService.UpdateMovie(model);

                if (response == null)
                {
                    return(BadRequest("Something went wrong updating the movie"));
                }
                return(Ok(response));
            }
            return(BadRequest("Please check the info you provided"));
        }
Ejemplo n.º 11
0
        public async Task <MovieCardResponseModel> CreateMovie(MovieCreateRequestModel movieCreateRequestModel)
        {
            var movie = new Movie
            {
                Title   = movieCreateRequestModel.Title,
                Budget  = movieCreateRequestModel.Budget,
                Revenue = movieCreateRequestModel.Revenue,
            };
            var response = await _movieRepository.AddAsync(movie);

            var createdMovie = new MovieCardResponseModel
            {
                Id      = response.Id,
                Title   = response.Title,
                Budget  = response.Budget,
                Revenue = response.Revenue,
            };

            return(createdMovie);
        }
Ejemplo n.º 12
0
        public async Task <MovieDetailsResponseModel> CreateMovie(MovieCreateRequestModel movieCreateRequest)
        {
            //check movie doesn't already exist
            var dbMovie = await _repo.GetByNameAsync(movieCreateRequest.Title);

            if (dbMovie != null && string.Equals(dbMovie.Title, movieCreateRequest.Title, StringComparison.CurrentCultureIgnoreCase))
            {
                throw new Exception("Movie Already Exits");
            }

            //proceed to add the movie
            var movie = new Movie();

            //add content from request to the entity
            PropertyCopy.Copy(movie, movieCreateRequest);

            var createdMovie = await _repo.AddAsync(movie);

            var response = new MovieDetailsResponseModel();

            PropertyCopy.Copy(response, createdMovie);
            return(response);
        }
Ejemplo n.º 13
0
 public Task CreateMovie(MovieCreateRequestModel model)
 {
     // take model and convert it to Movie Entity and send it to repository
     // if repository saves successfully return true/id:2
     throw new NotImplementedException();
 }
Ejemplo n.º 14
0
 public IActionResult Create(MovieCreateRequestModel model) //, string title, string TITLE, string abc, decimal BUDGET, decimal bud)
 {
     _movieService.CreateMovie(model);
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 15
0
 public async Task <IActionResult> CreateMovie(MovieCreateRequestModel movieCreateRequestModel)
 {
     return(View());
 }
Ejemplo n.º 16
0
 public IActionResult CreateMovie(MovieCreateRequestModel movieCreateRequestModel)
 {
     return(View());
 }
Ejemplo n.º 17
0
        public async Task <IActionResult> UpdateMovie(MovieCreateRequestModel request)
        {
            var movie = await _movieService.UpdateMovie(request);

            return(CreatedAtRoute("GetMovieById", new { id = movie.Id }, movie));
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> CreateMovie([FromBody] MovieCreateRequestModel movieCreateRequest)
        {
            var createdMovie = await _movieService.CreateMovie(movieCreateRequest);

            return(CreatedAtRoute("GetMovie", new { id = createdMovie.Id }, createdMovie));
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> UpdateMovie([FromBody] MovieCreateRequestModel movieCreateRequest)
        {
            var createdMovie = await _movieService.UpdateMovie(movieCreateRequest);

            return(Ok(createdMovie));
        }
Ejemplo n.º 20
0
 public IActionResult CreateMovie(MovieCreateRequestModel movieCreateRequestModel)
 {
     // save to database
     return(View());
 }
Ejemplo n.º 21
0
        public async Task <MovieDetailsResponseModel> CreateMovie(MovieCreateRequestModel model)
        {
            if (!_currentUserService.IsAdmin)
            {
                throw new HttpException(HttpStatusCode.Unauthorized, "You are not Authorized to create movie");
            }

            // var dbMovie = await _movieRepository.GetById(model.Id);

            //if (dbMovie != null)
            //{
            //    throw new ConflictException("Movie already exists");
            //}

            //ICollection<Genre> genres = new List<Genre>();
            //foreach (var g in model.Genres)
            //{
            //    genres.Add(new Genre
            //    {
            //        Id = g.Id,
            //        Name = g.Name,
            //    });
            //}
            var movie = new Movie
            {
                Title            = model.Title,
                Overview         = model.Overview,
                Tagline          = model.Tagline,
                Revenue          = model.Revenue,
                Budget           = model.Budget,
                ImdbUrl          = model.ImdbUrl,
                TmdbUrl          = model.TmdbUrl,
                PosterUrl        = model.PosterUrl,
                BackdropUrl      = model.BackdropUrl,
                OriginalLanguage = model.OriginalLanguage,
                ReleaseDate      = model.ReleaseDate,
                RunTime          = model.RunTime,
                Price            = model.Price,
                //Genres = genres,
            };
            var createdMovie = await _movieRepository.Add(movie);

            var response = new MovieDetailsResponseModel
            {
                Id          = createdMovie.Id,
                Title       = createdMovie.Title,
                Overview    = createdMovie.Overview,
                Tagline     = createdMovie.Tagline,
                Revenue     = createdMovie.Revenue,
                Budget      = createdMovie.Budget,
                ImdbUrl     = createdMovie.ImdbUrl,
                TmdbUrl     = createdMovie.TmdbUrl,
                PosterUrl   = createdMovie.PosterUrl,
                BackdropUrl = createdMovie.BackdropUrl,
                ReleaseDate = createdMovie.ReleaseDate,
                RunTime     = createdMovie.RunTime,
                Price       = createdMovie.Price,
                //Genres = model.Genres,
            };

            return(response);
        }
Ejemplo n.º 22
0
 public IActionResult CreateMovie(MovieCreateRequestModel movieCreateRequestModel)
 {
     // take the information from the View and Save it to Database
     return(View());
 }
Ejemplo n.º 23
0
 public void CreateMovie(MovieCreateRequestModel model)
 {
     // take model and convert it to Movie Entity and send it to repository
     // if repository saves successfully return true/id:2
 }
 public IActionResult Create(MovieCreateRequestModel model)
 {
     _movieService.CreateMovie(model);
     return(RedirectToAction("Index"));
 }