Ejemplo n.º 1
0
        public InsertMovieResponse InsertMovie(InsertMovieRequest request)
        {
            InsertMovieResponse response = new InsertMovieResponse()
            {
                IsSuccess = true
            };

            try
            {
                if (request.Movie == null)
                {
                    throw new MovieAppException("The movie is empty");
                }
                if (String.IsNullOrEmpty(request.Movie.Title))
                {
                    throw new MovieAppException("The movie title field is empty");
                }
                if (String.IsNullOrEmpty(request.Movie.Author))
                {
                    throw new MovieAppException("The movie author field is empty");
                }
                MoviesManager.InsertMovie(request.Movie);
            }
            catch (Exception e)
            {
                response.IsSuccess          = false;
                response.ErrorMessage       = e.Message;
                response.IsApplicationError = (e.GetType() == typeof(MovieAppException));
            }
            return(response);
        }