From a24099df3c8552fd52bba014251c59d30760656a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=91=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D1=81=D0=BA=D0=B0=D1=8F?= Date: Sun, 26 May 2024 13:45:07 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BA=D0=BE=D1=82=D1=80=D0=BE=D0=BB=D0=BB=D0=B5?= =?UTF-8?q?=D1=80,=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=D0=B0=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B2=D0=BE=D0=B4=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=20=D0=BB=D0=BE=D0=B3=D0=BE=D0=B2,=20=D0=BA=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D1=81=20=D0=B0=D0=BF=D0=B8=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD?= =?UTF-8?q?=D1=82,=20=D0=BF=D1=80=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PolyclinicWebAppSuretor/APIClient.cs | 44 ++++++++++++++ .../Controllers/HomeController.cs | 13 +++- .../PolyclinicWebAppSuretor.csproj | 11 +++- Polyclinic/PolyclinicWebAppSuretor/Program.cs | 14 +++++ .../Views/Home/Procedures.cshtml | 60 ++++++++++--------- .../PolyclinicWebAppSuretor/log4net.config | 16 +++++ 6 files changed, 127 insertions(+), 31 deletions(-) create mode 100644 Polyclinic/PolyclinicWebAppSuretor/APIClient.cs create mode 100644 Polyclinic/PolyclinicWebAppSuretor/log4net.config diff --git a/Polyclinic/PolyclinicWebAppSuretor/APIClient.cs b/Polyclinic/PolyclinicWebAppSuretor/APIClient.cs new file mode 100644 index 0000000..861457c --- /dev/null +++ b/Polyclinic/PolyclinicWebAppSuretor/APIClient.cs @@ -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(string requestUrl) + { + var response = _client.GetAsync(requestUrl); + var result = response.Result.Content.ReadAsStringAsync().Result; + if (response.Result.IsSuccessStatusCode) + { + return JsonConvert.DeserializeObject(result); + } + else + { + throw new Exception(result); + } + } + public static void PostRequest(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); + } + } + } +} diff --git a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs index b7bff79..832d428 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs @@ -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 _logger; + private readonly IProcedureLogic _procedureLogic; - public HomeController(ILogger logger) + public HomeController(ILogger logger, IProcedureLogic procedureLogic) { _logger = logger; + _procedureLogic = procedureLogic; } public IActionResult Index() @@ -30,7 +34,12 @@ namespace PolyclinicWebAppSuretor.Controllers public IActionResult Procedures() { - return View(); + List procedure = _procedureLogic.ReadList(null); + if (procedure == null) + { + procedure = new(); + } + return View(procedure); } public IActionResult Recipes() diff --git a/Polyclinic/PolyclinicWebAppSuretor/PolyclinicWebAppSuretor.csproj b/Polyclinic/PolyclinicWebAppSuretor/PolyclinicWebAppSuretor.csproj index c39167e..0e6337b 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/PolyclinicWebAppSuretor.csproj +++ b/Polyclinic/PolyclinicWebAppSuretor/PolyclinicWebAppSuretor.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -7,10 +7,13 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive + + @@ -20,4 +23,10 @@ + + + Always + + + diff --git a/Polyclinic/PolyclinicWebAppSuretor/Program.cs b/Polyclinic/PolyclinicWebAppSuretor/Program.cs index 0727468..e5c6330 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Program.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Program.cs @@ -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(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); var app = builder.Build(); diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml index 31c7bb1..66cb332 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml @@ -44,35 +44,39 @@ - - 1 - - - Массаж пяточек - - - 12.04.2024 - - - 17.04.2024 - - - ммммммм - - - - - + @foreach (var item in Model) + + { + + @Html.DisplayFor(modelItem => item.Id) + + + @Html.DisplayFor(modelItem => item.Name) + + + @Html.DisplayFor(modelItem => item.DateStartProcedure) + + + @Html.DisplayFor(modelItem => item.DateStopProcedure) + + + @Html.DisplayFor(modelItem => item.Comment) + + + + + + + + + + + + + - - - - - - - - - + + } } diff --git a/Polyclinic/PolyclinicWebAppSuretor/log4net.config b/Polyclinic/PolyclinicWebAppSuretor/log4net.config new file mode 100644 index 0000000..fcdec65 --- /dev/null +++ b/Polyclinic/PolyclinicWebAppSuretor/log4net.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file