public async Task <IActionResult> GetImdbByWord(string movieWord)
        {
            //http://localhost:49270/api/imdbMovies/byWord/matrix/

            var id = User.Identity.Name;

            try
            {
                UserModel         userModel = userRepository.GetOneUserById(id);
                List <MovieModel> movies    = await imdbRepository.GetImdbByWord(userModel.userImdbPass, movieWord, id);

                return(Ok(movies));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }
        public async Task <IActionResult> GetImdbById(string movieId)
        {
            //http://localhost:49270/api/imdbMovies/byId/tt3896198/

            var id = User.Identity.Name;

            try
            {
                UserModel        userModel = userRepository.GetOneUserById(id);
                MovieExtendModel oneMovie  = await imdbRepository.GetImdbById(userModel.userImdbPass, movieId, id);

                return(Ok(oneMovie));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }
Пример #3
0
        public IActionResult UpdateUser(string id, UserModel userModel)
        {
            try
            {
                if (userModel == null)
                {
                    return(BadRequest("Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(BadRequest(errors));
                }

                userModel.userID = id;
                UserModel updatedUser = usersRepository.UpdateUser(userModel);
                return(Ok(updatedUser));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }
 public IActionResult AddMovie(MovieExtendModel movieModel)
 {
     try
     {
         if (movieModel == null)
         {
             return(BadRequest("Data is null."));
         }
         //if (!ModelState.IsValid)
         //{
         //	Errors errors = ErrorsHelper.GetErrors(ModelState);
         //	return BadRequest(errors);
         //}
         var id = User.Identity.Name;
         movieModel.userID = id;
         MovieExtendModel addedMovie = moviesExtendRepository.AddMovie(movieModel);
         return(StatusCode(StatusCodes.Status201Created, addedMovie));
     }
     catch (Exception ex)
     {
         Errors errors = ErrorsHelper.GetErrors(ex);
         return(StatusCode(StatusCodes.Status500InternalServerError, errors));
     }
 }