working totalResults and currentPage on the API

Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
haraldnilsen 2023-10-03 10:29:41 +02:00
parent d4b53e9912
commit 187c669495
4 changed files with 12 additions and 7 deletions

View file

@ -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);
}

View file

@ -5,9 +5,10 @@ namespace backend;
public class MovieResponse
{
public MovieResponse(string Response, int TotalResults, IEnumerable<MovieDB> Search) {
public MovieResponse(string Response, int TotalResults, int CurrentPage ,IEnumerable<MovieDB> 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<MovieDB> Search { get; set; }
}

View file

@ -36,15 +36,15 @@ var services = builder.Services.BuildServiceProvider();
using (var scope = services.CreateScope())
{
var context = scope.ServiceProvider.GetRequiredService<MovieDbContext>();
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))
{

View file

@ -1,2 +1,4 @@
docker-compose up -d
cd cinemateket
dotnet run