From 90a3478c85ae5c5eaab167246665a91a3488b501 Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Thu, 24 Aug 2023 19:24:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FichaBackend/Controllers/MainController.cs | 17 ++++++++++ .../Controllers/WeatherForecastController.cs | 32 ------------------- FichaBackend/DatabaseContext.cs | 14 ++++++++ FichaBackend/Dockerfile | 7 ++-- FichaBackend/FichaBackend.csproj | 19 ++++++++++- FichaBackend/WeatherForecast.cs | 12 ------- 6 files changed, 52 insertions(+), 49 deletions(-) create mode 100644 FichaBackend/Controllers/MainController.cs delete mode 100644 FichaBackend/Controllers/WeatherForecastController.cs create mode 100644 FichaBackend/DatabaseContext.cs delete mode 100644 FichaBackend/WeatherForecast.cs diff --git a/FichaBackend/Controllers/MainController.cs b/FichaBackend/Controllers/MainController.cs new file mode 100644 index 0000000..f0ae3f5 --- /dev/null +++ b/FichaBackend/Controllers/MainController.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Mvc; + +namespace FichaBackend.Controllers; + +[ApiController] +[Route("[controller]")] +public class MainController : ControllerBase +{ + + private readonly ILogger _logger; + + public MainController(ILogger logger) + { + _logger = logger; + } + +} \ No newline at end of file diff --git a/FichaBackend/Controllers/WeatherForecastController.cs b/FichaBackend/Controllers/WeatherForecastController.cs deleted file mode 100644 index 3a80ae4..0000000 --- a/FichaBackend/Controllers/WeatherForecastController.cs +++ /dev/null @@ -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 _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable 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(); - } -} \ No newline at end of file diff --git a/FichaBackend/DatabaseContext.cs b/FichaBackend/DatabaseContext.cs new file mode 100644 index 0000000..7633b49 --- /dev/null +++ b/FichaBackend/DatabaseContext.cs @@ -0,0 +1,14 @@ +using Microsoft.EntityFrameworkCore; + +namespace FichaBackend +{ + public class DatabaseContext : DbContext + { + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + } + + public DatabaseContext(DbContextOptions options) : base(options) { } + } +} diff --git a/FichaBackend/Dockerfile b/FichaBackend/Dockerfile index 8030b99..293743a 100644 --- a/FichaBackend/Dockerfile +++ b/FichaBackend/Dockerfile @@ -1,14 +1,13 @@ FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base WORKDIR /app EXPOSE 80 -EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /src -COPY ["FichaBackend/FichaBackend.csproj", "FichaBackend/"] -RUN dotnet restore "FichaBackend/FichaBackend.csproj" +COPY ["FichaBackend.csproj", "FichaBackend.csproj"] +RUN dotnet restore "FichaBackend.csproj" COPY . . -WORKDIR "/src/FichaBackend" +WORKDIR "/src" RUN dotnet build "FichaBackend.csproj" -c Release -o /app/build FROM build AS publish diff --git a/FichaBackend/FichaBackend.csproj b/FichaBackend/FichaBackend.csproj index 1614fe2..b746a16 100644 --- a/FichaBackend/FichaBackend.csproj +++ b/FichaBackend/FichaBackend.csproj @@ -6,10 +6,27 @@ enable Linux + + + ApiDocumentation.xml + + + + ApiDocumentation.xml + 1701;1702;IL2121,1591 + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + + + diff --git a/FichaBackend/WeatherForecast.cs b/FichaBackend/WeatherForecast.cs deleted file mode 100644 index 40760a4..0000000 --- a/FichaBackend/WeatherForecast.cs +++ /dev/null @@ -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; } -} \ No newline at end of file