This commit is contained in:
Владимир Данилов 2024-05-01 23:10:05 +04:00
parent 47a6cd86a6
commit 7c0c56acb7
17 changed files with 467 additions and 25 deletions

View File

@ -7,7 +7,7 @@ using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddLog4Net("log4net.config");
//builder.Logging.AddLog4Net("log4net.config");
// Add services to the container.

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="D:\ULSTU\Семестр 4\РПП Coursework\VeterinaryClinic/log-${shortdate}.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>

View File

@ -14,8 +14,7 @@ namespace VeterinaryClinicWebApp
{
_client.BaseAddress = new Uri(configuration["IPAddress"]);
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new
MediaTypeWithQualityHeaderValue("application/json"));
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest<T>(string requestUrl)

View File

@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using VeterinaryClinicWebApp.Models;
namespace VeterinaryClinicWebApp.Controllers
{
public class AnimalController : Controller
{
private readonly ILogger<AnimalController> _logger;
public AnimalController(ILogger<AnimalController> logger)
{
_logger = logger;
}
public IActionResult Animals()
{
return View();
}
public IActionResult CreateAnimal()
{
return View();
}
public IActionResult UpdateAnimal()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

View File

@ -23,6 +23,15 @@ public class HomeController : Controller
return View();
}
public IActionResult Enter()
{
return View();
}
public IActionResult Register()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{

View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using VeterinaryClinicWebApp.Models;
namespace VeterinaryClinicWebApp.Controllers
{
public class MedicationController : Controller
{
private readonly ILogger<MedicationController> _logger;
public MedicationController(ILogger<MedicationController> logger)
{
_logger = logger;
}
public IActionResult Medications()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using VeterinaryClinicWebApp.Models;
namespace VeterinaryClinicWebApp.Controllers
{
public class ServiceController : Controller
{
private readonly ILogger<ServiceController> _logger;
public ServiceController(ILogger<ServiceController> logger)
{
_logger = logger;
}
public IActionResult Services()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using VeterinaryClinicWebApp.Models;
namespace VeterinaryClinicWebApp.Controllers
{
public class VaccinationController : Controller
{
private readonly ILogger<VaccinationController> _logger;
public VaccinationController(ILogger<VaccinationController> logger)
{
_logger = logger;
}
public IActionResult Vaccinations()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using VeterinaryClinicWebApp.Models;
namespace VeterinaryClinicWebApp.Controllers
{
public class VisitController : Controller
{
private readonly ILogger<VisitController> _logger;
public VisitController(ILogger<VisitController> logger)
{
_logger = logger;
}
public IActionResult Visits()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

View File

@ -1,3 +1,5 @@
using VeterinaryClinicWebApp;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
@ -5,6 +7,8 @@ builder.Services.AddControllersWithViews();
var app = builder.Build();
APIClient.Connect(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{

View File

@ -17,11 +17,4 @@
<ProjectReference Include="..\VeterinaryClinicDataModels\VeterinaryClinicDataModels.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Visit\" />
<Folder Include="Views\Vaccination\" />
<Folder Include="Views\Service\" />
<Folder Include="Views\Medication\" />
</ItemGroup>
</Project>

View File

@ -10,6 +10,14 @@
<h2 class="display-4">Личные данные</h2>
</div>
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
}
<form method="post" style="margin-top: 50px">
<!-- ФИО -->
<div class="row">

View File

@ -0,0 +1,64 @@
@using VeterinaryClinicContracts.ViewModels
@model List<MedicationViewModel>
@{
ViewData["Title"] = "Медкаменты";
}
<div class="text-center">
<h1 class="display-4">Медикаменты</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateMedication">Создать медикамент</a>
</p>
<table class="table">
<thead>
<tr>
<th>Номер</th>
<th>Название</th>
<th>Описание</th>
</tr>
</thead>
<tbody>
@foreach (var medication in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => medication.Id)</td>
<td>@Html.DisplayFor(modelItem => medication.Name)</td>
<td>@Html.DisplayFor(modelItem => medication.Description)</td>
<td>
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateMedication", "/Medication", new { id = medication.Id })'">Изменить</button></p>
</td>
<td>
<p><button type="button" class="btn btn-primary" onclick="deleteMedication(@medication.Id)">Удалить</button></p>
</td>
</tr>
}
</tbody>
</table>
}
</div>
@section scripts {
<script>
function deleteMedication(id) {
if (confirm("Вы уверены, что хотите удалить медикамент?")) {
$.post('@Url.Action("DeleteMedication", "/Medication")' + '/' + id, function () {
window.location.reload();
});
}
}
</script>
}

View File

@ -0,0 +1,66 @@
@using VeterinaryClinicContracts.ViewModels
@model List<ServiceViewModel>
@{
ViewData["Title"] = "Услуги";
}
<div class="text-center">
<h1 class="display-4">Услуги</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateService">Создать услугу</a>
</p>
<table class="table">
<thead>
<tr>
<th>Номер</th>
<th>Название</th>
<th>Цена</th>
<th>Медикамент</th>
</tr>
</thead>
<tbody>
@foreach (var service in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => service.Id)</td>
<td>@Html.DisplayFor(modelItem => service.Name)</td>
<td>@Html.DisplayFor(modelItem => service.Cost)</td>
<td>@Html.DisplayFor(modelItem => service.MedicationName)</td>
<td>
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateService", "/Service", new { id = service.Id })'">Изменить</button></p>
</td>
<td>
<p><button type="button" class="btn btn-primary" onclick="deleteService(@service.Id)">Удалить</button></p>
</td>
</tr>
}
</tbody>
</table>
}
</div>
@section scripts {
<script>
function deleteService(id) {
if (confirm("Вы уверены, что хотите удалить медикамент?")) {
$.post('@Url.Action("DeleteService", "/Service")' + '/' + id, function () {
window.location.reload();
});
}
}
</script>
}

View File

@ -18,13 +18,17 @@
</button>
<div class="navbar-collapse collapse d-sm-inline-flex flex-smrow-reverse">
<ul class="navbar-nav flex-grow-1">
<!-- Визиты -->
<!-- Личные данные -->
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Visit" asp-action="Visits">Пациенты</a>
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
<!-- Выписка визитов (привязка животных к визитам) -->
<!-- Вход -->
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Visit" asp-action="CreateVisitAnimals">Выписать визит</a>
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<!-- Регистрация -->
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li>
<!-- Животные -->
<li class="nav-item">
@ -42,18 +46,14 @@
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Medication" asp-action="Medications">Медикаменты</a>
</li>
<!-- Личные данные -->
<!-- Визиты -->
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
<!-- Вход -->
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<!-- Регистрация -->
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Регистрация</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Visit" asp-action="Visits">Визиты</a>
</li>
<!-- Выписка визитов (привязка животных к визитам) -->
@* <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Visit" asp-action="CreateVisitAnimals">Выписать визит</a>
</li> *@
</ul>
</div>
</div>

View File

@ -0,0 +1,69 @@
@using VeterinaryClinicContracts.ViewModels
@model List<VaccinationViewModel>
@{
ViewData["Title"] = "Прививки";
}
<div class="text-center">
<h1 class="display-4">Прививки</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateVaccination">Создать прививку</a>
</p>
<table class="table">
<thead>
<tr>
<th>Номер</th>
<th>Название прививки</th>
<th>Порода животного</th>
<th>Срок действия прививки</th>
<th>Дата укола</th>
</tr>
</thead>
<tbody>
@foreach (var vaccination in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => vaccination.Id)</td>
<td>@Html.DisplayFor(modelItem => vaccination.Name)</td>
<td>@Html.DisplayFor(modelItem => vaccination.AnimalBreed)</td>
<td>@Html.DisplayFor(modelItem => vaccination.ValidityPeriod)</td>
<td>@Html.DisplayFor(modelItem => vaccination.DateInjection.ToShortDateString())</td>
<td>
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateVaccination", "/Vaccination", new { id = vaccination.Id })'">Изменить</button></p>
</td>
<td>
<p><button type="button" class="btn btn-primary" onclick="deleteVaccination(@vaccination.Id)">Удалить</button></p>
</td>
</tr>
}
</tbody>
</table>
}
</div>
@section scripts {
<script>
function deleteVaccination(id) {
if (confirm("Вы уверены, что хотите удалить прививку?")) {
$.post('@Url.Action("DeleteVaccination", "/Vaccination")' + '/' + id, function () {
window.location.reload();
});
}
}
</script>
}

View File

@ -0,0 +1,69 @@
@using VeterinaryClinicContracts.ViewModels
@model List<VisitViewModel>
@{
ViewData["Title"] = "Визиты";
}
<div class="text-center">
<h1 class="display-4">Визиты</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateVisit">Создать визит</a>
</p>
<table class="table">
<thead>
<tr>
<th>Номер</th>
<th>Дата визита</th>
<th>Пользователь</th>
<th>Животные</th>
<th>Услуги</th>
</tr>
</thead>
<tbody>
@foreach (var visit in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => visit.Id)</td>
<td>@Html.DisplayFor(modelItem => visit.Date.ToShortDateString())</td>
<td>@Html.DisplayFor(modelItem => visit.UserFullName)</td>
<td>@Html.DisplayFor(modelItem => visit.VisitAnimals)</td>
<td>@Html.DisplayFor(modelItem => visit.VisitServices)</td>
<td>
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateVisit", "/Visit", new { id = visit.Id })'">Изменить</button></p>
</td>
<td>
<p><button type="button" class="btn btn-primary" onclick="deleteVisit(@visit.Id)">Удалить</button></p>
</td>
</tr>
}
</tbody>
</table>
}
</div>
@section scripts {
<script>
function deleteVisit(id) {
if (confirm("Вы уверены, что хотите удалить визит?")) {
$.post('@Url.Action("DeleteVisit", "/Visit")' + '/' + id, function () {
window.location.reload();
});
}
}
</script>
}