diff --git a/backend/cinemateket/Controllers/MovieController.cs b/backend/cinemateket/Controllers/MovieController.cs index a2bfd93..dede73d 100644 --- a/backend/cinemateket/Controllers/MovieController.cs +++ b/backend/cinemateket/Controllers/MovieController.cs @@ -71,7 +71,7 @@ public class MovieController: ControllerBase return StatusCode(204, "No Content"); } - MovieResponse Response = new MovieResponse("OK", resultTake.Count(), resultTake); + MovieResponse Response = new MovieResponse("OK", totalMovies, pageNumber ,resultTake); return Ok(Response); } diff --git a/backend/cinemateket/Models/MovieResponse.cs b/backend/cinemateket/Models/MovieResponse.cs index 6f17b37..1d643fd 100644 --- a/backend/cinemateket/Models/MovieResponse.cs +++ b/backend/cinemateket/Models/MovieResponse.cs @@ -5,9 +5,10 @@ namespace backend; public class MovieResponse { - public MovieResponse(string Response, int TotalResults, IEnumerable Search) { + public MovieResponse(string Response, int TotalResults, int CurrentPage ,IEnumerable Search) { this.Response = Response; this.TotalResults = TotalResults; + this.CurrentPage = CurrentPage; this.Search = Search; } @@ -15,5 +16,7 @@ public class MovieResponse public int TotalResults { get; set; } + public int CurrentPage { get; set; } + public IEnumerable Search { get; set; } } diff --git a/backend/cinemateket/Program.cs b/backend/cinemateket/Program.cs index b7f544f..85a4a6b 100644 --- a/backend/cinemateket/Program.cs +++ b/backend/cinemateket/Program.cs @@ -36,15 +36,15 @@ var services = builder.Services.BuildServiceProvider(); using (var scope = services.CreateScope()) { var context = scope.ServiceProvider.GetRequiredService(); - context.Database.EnsureCreated(); + + if (context.Database.EnsureCreated()) + { + context.Database.Migrate(); + } // Check if movies are already inserted to avoid duplicate insertion if (!context.Movies.Any()) { - using (context) - { - context.Database.Migrate(); - } using (var reader = new StreamReader("public/DbMockData.csv")) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { diff --git a/backend/start.sh b/backend/start.sh index e3048e4..3111271 100644 --- a/backend/start.sh +++ b/backend/start.sh @@ -1,2 +1,4 @@ docker-compose up -d + +cd cinemateket dotnet run \ No newline at end of file