Exemple #1
0
        public bool BatchProcess(BatchMovieInput batchJob)
        {
            Movie newMovieInfo = new Movie();

            foreach (var curMovie in batchJob.MovieList)
            {
                newMovieInfo.MovieId     = curMovie.Id;
                newMovieInfo.Genre       = batchJob.Genre;
                newMovieInfo.ReleaseYear = batchJob.ReleaseYear;
                newMovieInfo.Status      = curMovie.Status;
                newMovieInfo.Title       = batchJob.Title;
                newMovieInfo.Upc         = batchJob.Upc;

                bool result = UpdateMovieInfo(newMovieInfo);

                if (!result)
                {
                    return(false);
                }
            }

            return(true);
        }
        public IActionResult Create([FromBody] BatchMovieInput batchJob)  // Add New Movie
        {
            var newMovieUtils = new MovieUtils();

            try
            {
                if (batchJob.MovieList.Count > 0)
                {
                    bool result = newMovieUtils.BatchProcess(batchJob);

                    if (result)
                    {
                        return(Ok());
                    }
                    return(StatusCode(500, "Couldnt complete the batch Processing!"));
                }
                return(StatusCode(500, "You Selected 0 Copies of the movie...  Nothing to do!"));
            }
            catch (Exception e)
            {
                return(StatusCode(500, "Couldn't Process the batch job!" + e));
            }
        }