исправлен котроллер, сделала вывод списка процедур
добавила файл логов, класс апиклиент, прописала зависимости
This commit is contained in:
parent
9f44ad75be
commit
a24099df3c
44
Polyclinic/PolyclinicWebAppSuretor/APIClient.cs
Normal file
44
Polyclinic/PolyclinicWebAppSuretor/APIClient.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using PolyclinicContracts.ViewModels;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace PolyclinicWebAppSuretor
|
||||||
|
{
|
||||||
|
public class APIClient
|
||||||
|
{
|
||||||
|
private static readonly HttpClient _client = new();
|
||||||
|
public static UserViewModel? User { get; set; } = null;
|
||||||
|
|
||||||
|
public static void Connect(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||||
|
_client.DefaultRequestHeaders.Accept.Clear();
|
||||||
|
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
|
}
|
||||||
|
public static T? GetRequest<T>(string requestUrl)
|
||||||
|
{
|
||||||
|
var response = _client.GetAsync(requestUrl);
|
||||||
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
|
if (response.Result.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return JsonConvert.DeserializeObject<T>(result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void PostRequest<T>(string requestUrl, T model)
|
||||||
|
{
|
||||||
|
var json = JsonConvert.SerializeObject(model);
|
||||||
|
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
var response = _client.PostAsync(requestUrl, data);
|
||||||
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
|
if (!response.Result.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using PolyclinicContracts.BusinessLogicsContracts;
|
||||||
|
using PolyclinicContracts.ViewModels;
|
||||||
using PolyclinicWebAppSuretor.Models;
|
using PolyclinicWebAppSuretor.Models;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
@ -7,10 +9,12 @@ namespace PolyclinicWebAppSuretor.Controllers
|
|||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<HomeController> _logger;
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
private readonly IProcedureLogic _procedureLogic;
|
||||||
|
|
||||||
public HomeController(ILogger<HomeController> logger)
|
public HomeController(ILogger<HomeController> logger, IProcedureLogic procedureLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_procedureLogic = procedureLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -30,7 +34,12 @@ namespace PolyclinicWebAppSuretor.Controllers
|
|||||||
|
|
||||||
public IActionResult Procedures()
|
public IActionResult Procedures()
|
||||||
{
|
{
|
||||||
return View();
|
List<ProcedureViewModel> procedure = _procedureLogic.ReadList(null);
|
||||||
|
if (procedure == null)
|
||||||
|
{
|
||||||
|
procedure = new();
|
||||||
|
}
|
||||||
|
return View(procedure);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Recipes()
|
public IActionResult Recipes()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
@ -7,10 +7,13 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="log4net.Extensions.AspNetCore" Version="1.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.16">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.16">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -20,4 +23,10 @@
|
|||||||
<ProjectReference Include="..\PolyclinicDataModels\PolyclinicDataModels.csproj" />
|
<ProjectReference Include="..\PolyclinicDataModels\PolyclinicDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Update="log4net.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,21 @@
|
|||||||
|
using PolyclinicBusinessLogic.BusinessLogics;
|
||||||
|
using PolyclinicContracts.BusinessLogicsContracts;
|
||||||
|
using PolyclinicContracts.StoragesContracts;
|
||||||
|
using PolyclinicDatabaseImplement.Implements;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||||
|
builder.Logging.AddLog4Net("log4net.config");
|
||||||
|
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
|
||||||
|
builder.Services.AddTransient<IMedicamentLogic, MedicamentLogic>();
|
||||||
|
builder.Services.AddTransient<IRecipeLogic, RecipeLogic>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
|
||||||
|
builder.Services.AddTransient<IMedicamentStorage, MedicamentStorage>();
|
||||||
|
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
@ -44,35 +44,39 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<td>
|
@foreach (var item in Model)
|
||||||
1
|
|
||||||
</td>
|
{
|
||||||
<td>
|
<td>
|
||||||
Массаж пяточек
|
@Html.DisplayFor(modelItem => item.Id)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
12.04.2024
|
@Html.DisplayFor(modelItem => item.Name)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
17.04.2024
|
@Html.DisplayFor(modelItem => item.DateStartProcedure)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
ммммммм
|
@Html.DisplayFor(modelItem => item.DateStopProcedure)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="CreateProcedure">
|
@Html.DisplayFor(modelItem => item.Comment)
|
||||||
<svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none" xmlns="http://www.w3.org/2000/svg">
|
</td>
|
||||||
<path d="M105.5 26L37 114.5C34.5 117 16.3 121.7 7.5 122.5C79.1 34.1 101 5.5 102 4C104.833 4.5 119.3 14.6 122.5 21C105 44 98.5 55 111.5 58.5" stroke="#008315" stroke-width="6" stroke-linecap="round" />
|
<td>
|
||||||
|
<a asp-action="CreateProcedure">
|
||||||
|
<svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M105.5 26L37 114.5C34.5 117 16.3 121.7 7.5 122.5C79.1 34.1 101 5.5 102 4C104.833 4.5 119.3 14.6 122.5 21C105 44 98.5 55 111.5 58.5" stroke="#008315" stroke-width="6" stroke-linecap="round" />
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M44.5 123C4.99995 119.5 -11.8431 56.4293 24 19.5C40.5 2.50001 72.5 -5.5 101.5 27.5L115.5 14.5" stroke="#D10000" stroke-width="8" stroke-linecap="round" />
|
||||||
|
<path d="M65.2123 159.963L56 60.0001C88.0236 76.3307 119.521 77.4194 149 60.0001C141.63 142.346 140.08 160.953 140.226 159.963H65.2123Z" stroke="#D10000" stroke-width="8" />
|
||||||
|
<path d="M121 36L101.582 55L75 31" stroke="#D10000" stroke-width="8" stroke-linecap="round" />
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</td>
|
||||||
</td>
|
}
|
||||||
<td>
|
|
||||||
<svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M44.5 123C4.99995 119.5 -11.8431 56.4293 24 19.5C40.5 2.50001 72.5 -5.5 101.5 27.5L115.5 14.5" stroke="#D10000" stroke-width="8" stroke-linecap="round" />
|
|
||||||
<path d="M65.2123 159.963L56 60.0001C88.0236 76.3307 119.521 77.4194 149 60.0001C141.63 142.346 140.08 160.953 140.226 159.963H65.2123Z" stroke="#D10000" stroke-width="8" />
|
|
||||||
<path d="M121 36L101.582 55L75 31" stroke="#D10000" stroke-width="8" stroke-linecap="round" />
|
|
||||||
</svg>
|
|
||||||
</td>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
}
|
}
|
||||||
|
16
Polyclinic/PolyclinicWebAppSuretor/log4net.config
Normal file
16
Polyclinic/PolyclinicWebAppSuretor/log4net.config
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<log4net>
|
||||||
|
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
|
||||||
|
<file value="logs/polyclinicsuretorclient.log" />
|
||||||
|
<appendToFile value="true" />
|
||||||
|
<maximumFileSize value="100KB" />
|
||||||
|
<maxSizeRollBackups value="2" />
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<root>
|
||||||
|
<level value="TRACE" />
|
||||||
|
<appender-ref ref="RollingFile" />
|
||||||
|
</root>
|
||||||
|
</log4net>
|
Loading…
Reference in New Issue
Block a user