Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> GetImdbById(string getByID)
        {
            try
            {
                IncomingWebRequestContext woc = WebOperationContext.Current.IncomingRequest;
                string userPass = woc.Headers["userPass"];
                userPass = Encoding.UTF8.GetString(Convert.FromBase64String(userPass));

                string userID = userRepository.ReturnUserIdByImdbPass(userPass);

                HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(JsonConvert.SerializeObject(await imdbRepository.GetImdbById(userPass, getByID, userID)))
                };
                return(hrm);
            }
            catch (Exception ex)
            {
                Errors errors           = ErrorsHelper.GetErrors(ex);
                HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(errors.ToString())
                };
                return(hrm);
            }
        }
        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));
            }
        }
Ejemplo n.º 3
0
        public async Task <HttpResponseMessage> GetImdbById(string movieId)
        {
            //http://localhost:49270/api/imdbMovies/byId/tt3896198/

            string id = base.ControllerContext.RequestContext.Principal.Identity.Name;

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

                return(Request.CreateResponse(HttpStatusCode.OK, oneMovie));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors));
            }
        }