🚧 working on get-endpoint

Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
haraldnilsen 2023-09-19 09:48:59 +02:00
parent f19dda9a42
commit c662c48e59
2 changed files with 6 additions and 43 deletions

View file

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Writers;
namespace backend.Controllers;
@ -6,24 +7,18 @@ namespace backend.Controllers;
[Route("[controller]")]
public class MovieController: ControllerBase
{
private readonly MovieDbContext _context;
private readonly ILogger<MovieController> _logger;
public MovieController(ILogger<MovieController> logger)
public MovieController(ILogger<MovieController> logger, MovieDbContext context)
{
_logger = logger;
_context = context;
}
[HttpGet(Name = "GetMovie")]
public IEnumerable<Movie> Get()
public IEnumerable<MovieDB> Get()
{
return Enumerable.Range(1, 5).Select(index => new Movie
{
Title = "Title",
Year = "Year",
imdbID = "imdbID",
Type = "Type",
Poster = "Poster"
})
.ToArray();
return _context.Movies.ToList();
}
}

View file

@ -1,32 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace backend.Controllers;
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}