Ejemplo n.º 1
0
        public IHttpActionResult Get(int id)
        {
            var loggedUserId = HttpContext.Current.GetOwinContext().GetUserId();

            var request = new GetMovieGenreRequest()
            {
                RequestToken = Guid.NewGuid(),
                UserId       = loggedUserId,
                Id           = id
            };

            var moviegenresResponse = _movieGenreService.GetMovieGenre(request);

            if (!moviegenresResponse.Success)
            {
                return(BadRequest(moviegenresResponse.Message));
            }

            return(Ok(
                       new
            {
                moviegenres = moviegenresResponse.MovieGenres.MapToViewModels()
            }
                       ));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handling get request and response
        /// </summary>
        /// <param name="request">Messaging.MovieGenres.GetMovieGenreRequest</param>
        /// <returns>Messaging.MovieGenres.GetMovieGenreResponse</returns>
        public GetMovieGenreResponse GetMovieGenre(GetMovieGenreRequest request)
        {
            var response = new GetMovieGenreResponse()
            {
                Request       = request,
                ResponseToken = Guid.NewGuid()
            };

            try
            {
                response.MovieGenres = _repository.FindAllBy(request.Id).MapToViews();
                response.Success     = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Success = false;
            }

            return(response);
        }