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