public IActionResult UpdateMovie(string code, [FromBody] Movie movie) { try { _logger.LogInformation($"api/Movies/CRUD:UpdateMovie: " + $"Code: {code} " + $"Movie: {movie.ToString()}"); return(Ok(_businessLogicLayer.UpdateMovie(code, movie))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
private static void TestUpdateMovie(string code) { Movie movie = null; string originalTitle = string.Empty; Console.WriteLine($"Testing updating movie '{code}'."); movie = _businessLogicLayer.ReadMovie(code); if (movie != null) { originalTitle = movie.OriginalTitle; movie.OriginalTitle = @"Test Update"; Console.WriteLine($"Update Success: {_businessLogicLayer.UpdateMovie(code, movie).ToString()}."); movie = _businessLogicLayer.ReadMovie(code); Console.WriteLine($"New Title: {movie.OriginalTitle}."); movie.OriginalTitle = originalTitle; Console.WriteLine($"Update Success: {_businessLogicLayer.UpdateMovie(code, movie).ToString()}."); movie = _businessLogicLayer.ReadMovie(code); Console.WriteLine($"Title set back to: {movie.OriginalTitle}."); } }