Merge branch 'stage9_10' of https://git.is.ulstu.ru/ns.potapov/PIbd-21_CourseWork_Polyclinic_BeSick into stage9_10
This commit is contained in:
commit
c26bbd5d6a
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 PolyclinicContracts.BusinessLogicsContracts;
|
||||
using PolyclinicContracts.ViewModels;
|
||||
using PolyclinicWebAppSuretor.Models;
|
||||
using System.Diagnostics;
|
||||
|
||||
@ -7,10 +9,12 @@ namespace PolyclinicWebAppSuretor.Controllers
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IProcedureLogic _procedureLogic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
public HomeController(ILogger<HomeController> logger, IProcedureLogic procedureLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_procedureLogic = procedureLogic;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@ -30,7 +34,12 @@ namespace PolyclinicWebAppSuretor.Controllers
|
||||
|
||||
public IActionResult Procedures()
|
||||
{
|
||||
return View();
|
||||
List<ProcedureViewModel> procedure = _procedureLogic.ReadList(null);
|
||||
if (procedure == null)
|
||||
{
|
||||
procedure = new();
|
||||
}
|
||||
return View(procedure);
|
||||
}
|
||||
|
||||
public IActionResult Recipes()
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@ -7,10 +7,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="log4net.Extensions.AspNetCore" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.16">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -20,4 +23,10 @@
|
||||
<ProjectReference Include="..\PolyclinicDataModels\PolyclinicDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="log4net.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,7 +1,21 @@
|
||||
using PolyclinicBusinessLogic.BusinessLogics;
|
||||
using PolyclinicContracts.BusinessLogicsContracts;
|
||||
using PolyclinicContracts.StoragesContracts;
|
||||
using PolyclinicDatabaseImplement.Implements;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
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();
|
||||
|
||||
|
@ -44,20 +44,23 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
|
||||
{
|
||||
<td>
|
||||
1
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
Массаж пяточек
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
12.04.2024
|
||||
@Html.DisplayFor(modelItem => item.DateStartProcedure)
|
||||
</td>
|
||||
<td>
|
||||
17.04.2024
|
||||
@Html.DisplayFor(modelItem => item.DateStopProcedure)
|
||||
</td>
|
||||
<td>
|
||||
ммммммм
|
||||
@Html.DisplayFor(modelItem => item.Comment)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="CreateProcedure">
|
||||
@ -73,6 +76,7 @@
|
||||
<path d="M121 36L101.582 55L75 31" stroke="#D10000" stroke-width="8" stroke-linecap="round" />
|
||||
</svg>
|
||||
</td>
|
||||
}
|
||||
</tbody>
|
||||
</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