✨ migrations get automatically applied when running proj
Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
1c19ca4ee2
commit
5cfc2653bb
5 changed files with 18 additions and 5 deletions
|
@ -71,7 +71,9 @@ public class MovieController: ControllerBase
|
||||||
return StatusCode(204, "No Content");
|
return StatusCode(204, "No Content");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(resultTake);
|
MovieResponse Response = new MovieResponse("OK", resultTake.Count(), resultTake);
|
||||||
|
|
||||||
|
return Ok(Response);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,9 +4,16 @@ namespace backend;
|
||||||
|
|
||||||
public class MovieResponse
|
public class MovieResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public MovieResponse(string Response, int TotalResults, IEnumerable<MovieDB> Search) {
|
||||||
|
this.Response = Response;
|
||||||
|
this.TotalResults = TotalResults;
|
||||||
|
this.Search = Search;
|
||||||
|
}
|
||||||
|
|
||||||
public string Response { get; set; }
|
public string Response { get; set; }
|
||||||
|
|
||||||
public string TotalResults { get; set; }
|
public int TotalResults { get; set; }
|
||||||
|
|
||||||
public List<Movie> Search { get; set; }
|
public IEnumerable<MovieDB> Search { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,11 @@ using (var scope = services.CreateScope())
|
||||||
var context = scope.ServiceProvider.GetRequiredService<MovieDbContext>();
|
var context = scope.ServiceProvider.GetRequiredService<MovieDbContext>();
|
||||||
context.Database.EnsureCreated();
|
context.Database.EnsureCreated();
|
||||||
|
|
||||||
|
using (context)
|
||||||
|
{
|
||||||
|
context.Database.Migrate();
|
||||||
|
}
|
||||||
|
|
||||||
// Check if movies are already inserted to avoid duplicate insertion
|
// Check if movies are already inserted to avoid duplicate insertion
|
||||||
if (!context.Movies.Any())
|
if (!context.Movies.Any())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { movieObject, movieResponse } from '../types/movie'
|
import { movieResponse } from '../types/movie'
|
||||||
|
|
||||||
//const API_MOVIE_KEY = import.meta.env.VITE_MOVIE_API_KEY
|
//const API_MOVIE_KEY = import.meta.env.VITE_MOVIE_API_KEY
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import type { movieObject } from '../../types/movie'
|
import type { movieObject } from '../../types/movie'
|
||||||
import Modal from 'react-modal'
|
import Modal from 'react-modal'
|
||||||
import q from 'qjuul'
|
import q from 'qjuul'
|
||||||
import { useState } from 'react'
|
|
||||||
|
|
||||||
interface MovieTableRowProps {
|
interface MovieTableRowProps {
|
||||||
movie: movieObject
|
movie: movieObject
|
||||||
|
|
Reference in a new issue