Настроил проект

This commit is contained in:
Sergey Karmanov 2023-08-24 19:24:33 +03:00
parent 2bf9117f18
commit 90a3478c85
Signed by: serega404
GPG Key ID: B6AD49C8C835460C
6 changed files with 52 additions and 49 deletions

View File

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
namespace FichaBackend.Controllers;
[ApiController]
[Route("[controller]")]
public class MainController : ControllerBase
{
private readonly ILogger<MainController> _logger;
public MainController(ILogger<MainController> logger)
{
_logger = logger;
}
}

View File

@ -1,32 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace FichaBackend.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

@ -0,0 +1,14 @@
using Microsoft.EntityFrameworkCore;
namespace FichaBackend
{
public class DatabaseContext : DbContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }
}
}

View File

@ -1,14 +1,13 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src WORKDIR /src
COPY ["FichaBackend/FichaBackend.csproj", "FichaBackend/"] COPY ["FichaBackend.csproj", "FichaBackend.csproj"]
RUN dotnet restore "FichaBackend/FichaBackend.csproj" RUN dotnet restore "FichaBackend.csproj"
COPY . . COPY . .
WORKDIR "/src/FichaBackend" WORKDIR "/src"
RUN dotnet build "FichaBackend.csproj" -c Release -o /app/build RUN dotnet build "FichaBackend.csproj" -c Release -o /app/build
FROM build AS publish FROM build AS publish

View File

@ -6,10 +6,27 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DocumentationFile>ApiDocumentation.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DocumentationFile>ApiDocumentation.xml</DocumentationFile>
<NoWarn>1701;1702;IL2121,1591</NoWarn>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9"/> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,12 +0,0 @@
namespace FichaBackend;
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; }
}