Compare commits

..

No commits in common. "ed9c6632c9d7baf6354a4bfda01d28499e76b691" and "c5f19037c3bcb537a49e1ddbd413c2d1483c4dc2" have entirely different histories.

9 changed files with 46 additions and 56 deletions

1
API/.gitignore vendored
View File

@ -1 +0,0 @@
database.sqlite3*

View File

@ -11,11 +11,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.6.24327.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0-preview.6.24327.4" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

View File

@ -1,9 +0,0 @@
using API.Models;
using Microsoft.EntityFrameworkCore;
namespace API;
public class AppDBContext(DbContextOptions<AppDBContext> options) : DbContext(options)
{
public DbSet<User> Users { get; set; }
}

View File

@ -1,20 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace API.Controllers
{
[ApiController]
[Route("[controller]")]
public class HealthCheckController(AppDBContext context) : ControllerBase
{
[HttpGet(Name = "HealthCheck")]
public StatusCodeResult Get()
{
if (!context.Database.CanConnect())
{
return new StatusCodeResult(500);
}
return Ok();
}
}
}

View File

@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace API.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();
}
}
}

View File

@ -1,11 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace API.Models;
public class User
{
public int Id { get; set; }
public string? Email { get; set; }
public string? Username { get; set; }
public string? Password { get; set; }
}

View File

@ -1,5 +1,3 @@
using Microsoft.EntityFrameworkCore;
namespace API
{
public class Program
@ -25,11 +23,6 @@ namespace API
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
IConfiguration Configuration = builder.Configuration;
var connectionString = Configuration.GetConnectionString("DefaultConnection") ?? Environment.GetEnvironmentVariable("DefaultConnection");
builder.Services.AddDbContext<AppDBContext>(options => options.UseSqlite(connectionString));
var app = builder.Build();
// Configure the HTTP request pipeline.

13
API/WeatherForecast.cs Normal file
View File

@ -0,0 +1,13 @@
namespace API
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

View File

@ -4,8 +4,5 @@
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"DefaultConnection": "Data Source=database.sqlite3"
}
}