Создал контроллер для диагнозов

This commit is contained in:
Никита Потапов 2024-05-23 14:58:59 +04:00
parent 9dea9260bb
commit 138d0b9c76
12 changed files with 191 additions and 66 deletions

View File

@ -12,7 +12,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
private ILogger _logger;
private ICourseStorage _courseStorage;
public CourseLogic(ILogger logger, ICourseStorage courseStorage)
public CourseLogic(ILogger<CourseLogic> logger, ICourseStorage courseStorage)
{
_logger = logger;
_courseStorage = courseStorage;

View File

@ -12,7 +12,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
private ILogger _logger;
private IDiagnoseStorage _diagnoseStorage;
public DiagnoseLogic(ILogger logger, IDiagnoseStorage diagnoseStorage)
public DiagnoseLogic(ILogger<DiagnoseLogic> logger, IDiagnoseStorage diagnoseStorage)
{
_logger = logger;
_diagnoseStorage = diagnoseStorage;

View File

@ -12,7 +12,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
private ILogger _logger;
private ISymptomStorage _symptomStorage;
public SymptomLogic(ILogger logger, ISymptomStorage symptomStorage)
public SymptomLogic(ILogger<SymptomLogic> logger, ISymptomStorage symptomStorage)
{
_logger = logger;
_symptomStorage = symptomStorage;

View File

@ -12,7 +12,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
private ILogger _logger;
private IUserStorage _userStorage;
public UserLogic(ILogger logger, IUserStorage userStorage)
public UserLogic(ILogger<UserLogic> logger, IUserStorage userStorage)
{
_logger = logger;
_userStorage = userStorage;

View File

@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Mvc;
using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.ViewModels;
using PolyclinicWebAppImplementer.Models;
namespace PolyclinicWebAppImplementer.Controllers
{
public class DiagnosesController : Controller
{
private readonly ILogger<DiagnosesController> _logger;
private readonly IDiagnoseLogic _diagnoseLogic;
public DiagnosesController(ILogger<DiagnosesController> logger, IDiagnoseLogic diagnoseLogic)
{
_logger = logger;
_diagnoseLogic = diagnoseLogic;
}
[HttpGet]
public IActionResult Index()
{
List<DiagnoseViewModel> diagnoses = _diagnoseLogic.ReadList(null);
if (diagnoses == null)
{
diagnoses = new();
}
return View(diagnoses);
}
}
}

View File

@ -7,6 +7,9 @@
</PropertyGroup>
<ItemGroup>
<Content Update="log4net.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="Views\Home\Course.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
@ -47,9 +50,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PolyclinicBusinessLogic\PolyclinicBusinessLogic.csproj" />
<ProjectReference Include="..\PolyclinicDatabaseImplement\PolyclinicDatabaseImplement.csproj" />
</ItemGroup>

View File

@ -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<IDiagnoseLogic, DiagnoseLogic>();
builder.Services.AddTransient<ICourseLogic, CourseLogic>();
builder.Services.AddTransient<ISymptomLogic, SymptomLogic>();
builder.Services.AddTransient<IDiagnoseStorage, DiagnoseStorage>();
builder.Services.AddTransient<ICourseStorage, CourseStorage>();
builder.Services.AddTransient<ISymptomStorage, SymptomStorage>();
var app = builder.Build();

View File

@ -2,21 +2,21 @@
{
public static class SiteMenuItems
{
public static (string Url, string Title) Index = ("", "Главная");
public static (string Url, string Title) Courses = ("Courses", "Курсы");
public static (string Url, string Title) Diagnoses = ("Diagnoses", "Болезни");
public static (string Url, string Title) Symptomes = ("Symptomes", "Симптомы");
public static (string Url, string Title) Symptom = ("Symptom", "Симптом");
public static (string Url, string Title) Diagnose = ("Diagnose", "Болезнь");
public static (string Url, string Title) Course = ("Course", "Курс");
public static (string Url, string Title) Login = ("Login", "Вход");
public static (string Url, string Title) Register = ("Register", "Регистрация");
public static (string Url, string Title) Privacy = ("Privacy", "Политика приватности");
public static (string Url, string Title) AddRecipeToCourse = ("AddRecipeToCourse", "Привязка рецепта");
public static (string Url, string Title) MedicamentsByDiagnoses = ("MedicamentsByDiagnoses", "Лекарства по болезням");
public static (string Url, string Title) DiagnosesReport = ("DiagnosesReport", "Отчет по болезням");
public static (string Controller, string Action, string Title) Index = ("Home", "", "Главная");
public static (string Controller, string Action, string Title) Courses = ("Home", "Courses", "Курсы");
public static (string Controller, string Action, string Title) Diagnoses = ("Diagnoses", "", "Болезни");
public static (string Controller, string Action, string Title) Symptomes = ("Home", "Symptomes", "Симптомы");
public static (string Controller, string Action, string Title) Symptom = ("Home", "Symptom", "Симптом");
public static (string Controller, string Action, string Title) Diagnose = ("Home", "Diagnose", "Болезнь");
public static (string Controller, string Action, string Title) Course = ("Home", "Course", "Курс");
public static (string Controller, string Action, string Title) Login = ("Home", "Login", "Вход");
public static (string Controller, string Action, string Title) Register = ("Home", "Register", "Регистрация");
public static (string Controller, string Action, string Title) Privacy = ("Home", "Privacy", "Политика приватности");
public static (string Controller, string Action, string Title) AddRecipeToCourse = ("Home", "AddRecipeToCourse", "Привязка рецепта");
public static (string Controller, string Action, string Title) MedicamentsByDiagnoses = ("Home", "MedicamentsByDiagnoses", "Лекарства по болезням");
public static (string Controller, string Action, string Title) DiagnosesReport = ("Home", "DiagnosesReport", "Отчет по болезням");
public static List<(string Url, string Title)> MenuItemsOrder = new List<(string Url, string Title)>
public static List<(string Controller, string Action, string Title)> MenuItemsOrder = new List<(string Controller, string Action, string Title)>
{
Index, Courses, Diagnoses, Symptomes, Login, Register, AddRecipeToCourse, MedicamentsByDiagnoses, DiagnosesReport
};

View File

@ -0,0 +1,48 @@
@using PolyclinicContracts.ViewModels
@model List<DiagnoseViewModel>
@{
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Diagnoses;
}
<div>
<div class="d-flex flex-row">
<a class="btn btn-primary" asp-action="Add" asp-controller="Diagnoses" title="Добавить">
Добавить болезнь
</a>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">Номер</th>
<th scope="col">Название</th>
<th scope="col">Начало</th>
<th scope="col">Конец</th>
<th scope="col">Комментарий</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<th scope="row">@item.Id</th>
<td>@item.Name</td>
<td>@item.DateStartDiagnose</td>
<td>@item.DateStopDiagnose</td>
<td>@item.Comment</td>
<td class="d-flex">
<a class="btn btn-danger me-1" title="Удалить">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash-fill" viewBox="0 0 16 16">
<path d="M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5M8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5m3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0" />
</svg>
</a>
<a class="btn btn-warning text-light" title="Редактировать" asp-action="Edit" asp-controller="Diagnoses">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-fill" viewBox="0 0 16 16">
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.5.5 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11z" />
</svg>
</a>
</td>
</tr>
}
</tbody>
</table>
</div>

View File

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace PolyclinicWebAppImplementer.Views.Diagnoses
{
public class IndexModel : PageModel
{
public void OnGet()
{
}
}
}

View File

@ -35,8 +35,8 @@
<li class="menu-item">
@Html.RouteLink(menuItem.Title, new
{
controller = "Home",
action = menuItem.Url
controller = menuItem.Controller,
action = menuItem.Action
}, new
{
@class = "nav-link text-dark" + (menuItem.Equals(ViewBag.SelectedSiteMenuItem) ? " fw-bold" : "")

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="logs/polyclinicimplementerclient.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>