Minor changes

This commit is contained in:
parent f57a08bc31
commit 11abd6a2a6
20 changed files with 139 additions and 28 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@
# User-specific files (MonoDevelop/Xamarin Studio) # User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs *.userprefs
Reports Reports
Logs
# Mono auto generated files # Mono auto generated files
mono_crash.* mono_crash.*

View File

@ -8,6 +8,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HospitalBusinessLogics.BusinessLogics namespace HospitalBusinessLogics.BusinessLogics
@ -159,9 +160,9 @@ namespace HospitalBusinessLogics.BusinessLogics
{ {
throw new ArgumentNullException("Не указано ФИО доктора", nameof(model.FullName)); throw new ArgumentNullException("Не указано ФИО доктора", nameof(model.FullName));
} }
if (string.IsNullOrEmpty(model.Email)) if (string.IsNullOrEmpty(model.Email) || !Regex.IsMatch(model.Email, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$", RegexOptions.IgnoreCase))
{ {
throw new ArgumentNullException("Не указана электронная почта (логин)", nameof(model.Email)); throw new ArgumentNullException("Невалидная электронная почта (логин)", nameof(model.Email));
} }
if (string.IsNullOrEmpty(model.Password)) if (string.IsNullOrEmpty(model.Password))
{ {

View File

@ -34,5 +34,33 @@ namespace HospitalContracts.ViewModels
/// Идентификатор рецепта /// Идентификатор рецепта
/// </summary> /// </summary>
public int RecipeId { get; set; } public int RecipeId { get; set; }
/// <summary>
/// Получить хэш-код
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return Id.GetHashCode();
}
/// <summary>
/// Сравнить объекты
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(object? obj)
{
if (this == obj)
{
return true;
}
if (obj != null && obj is DiseaseViewModel other)
{
return this.Id == other.Id;
}
return false;
}
} }
} }

View File

@ -29,5 +29,33 @@ namespace HospitalContracts.ViewModels
/// </summary> /// </summary>
[DisplayName("Описание лекарства")] [DisplayName("Описание лекарства")]
public string? Description { get; set; } public string? Description { get; set; }
/// <summary>
/// Получить хэш-код
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return Id.GetHashCode();
}
/// <summary>
/// Сравнить объекты
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(object? obj)
{
if (this == obj)
{
return true;
}
if (obj != null && obj is MedicineViewModel other)
{
return this.Id == other.Id;
}
return false;
}
} }
} }

View File

@ -38,5 +38,33 @@ namespace HospitalContracts.ViewModels
get; get;
set; set;
} = new(); } = new();
/// <summary>
/// Получить хэш-код
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return Id.GetHashCode();
}
/// <summary>
/// Сравнить объекты
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(object? obj)
{
if (this == obj)
{
return true;
}
if (obj != null && obj is ProcedureViewModel other)
{
return this.Id == other.Id;
}
return false;
}
} }
} }

View File

@ -125,7 +125,7 @@ namespace HospitalDatabaseImplement.Implements
return null; return null;
} }
disease.Update(model); disease.Update(context, model);
context.SaveChanges(); context.SaveChanges();
return disease.GetViewModel; return disease.GetViewModel;
} }

View File

@ -73,7 +73,7 @@ namespace HospitalDatabaseImplement.Models
/// Изменить сущность /// Изменить сущность
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
public void Update(DiseaseBindingModel model) public void Update(HospitalDatabase context, DiseaseBindingModel model)
{ {
if (model == null) if (model == null)
{ {
@ -82,7 +82,11 @@ namespace HospitalDatabaseImplement.Models
Name = model.Name; Name = model.Name;
Symptoms = model.Symptoms; Symptoms = model.Symptoms;
} RecipeId = model.RecipeId;
Recipe = context.Recipes
.First(x => x.Id == model.RecipeId);
}
/// <summary> /// <summary>
/// Получить модель представления /// Получить модель представления

View File

@ -294,7 +294,7 @@ namespace HospitalWebApp.Controllers
var result = new var result = new
{ {
allRecipes = allRecipes.Select(r => new { id = r.Id, issueDate = r.IssueDate }), allRecipes = allRecipes.Select(r => new { id = r.Id, issueDate = r.IssueDate.ToShortDateString() }),
patientRecipeIds = patientRecipeIds patientRecipeIds = patientRecipeIds
}; };

View File

@ -8,6 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.11" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -7,12 +7,17 @@ using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.StoragesContracts; using HospitalContracts.StoragesContracts;
using HospitalDatabaseImplement.Implements; using HospitalDatabaseImplement.Implements;
using HospitalWebApp; using HospitalWebApp;
using NLog.Extensions.Logging;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
builder.Services.AddControllersWithViews(); builder.Services.AddControllersWithViews();
// Logger service
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddNLog("nlog.config");
// Storage services // Storage services
builder.Services.AddTransient<IDoctorStorage, DoctorStorage>(); builder.Services.AddTransient<IDoctorStorage, DoctorStorage>();
builder.Services.AddTransient<IPatientStorage, PatientStorage>(); builder.Services.AddTransient<IPatientStorage, PatientStorage>();

View File

@ -26,7 +26,7 @@
<select name="recipe" id="recipe" class="form-control"> <select name="recipe" id="recipe" class="form-control">
@foreach (var recipe in ViewBag.Recipes) @foreach (var recipe in ViewBag.Recipes)
{ {
<option value="@recipe.Id">@recipe.Id - @recipe.IssueDate</option> <option value="@recipe.Id">@recipe.Id - @recipe.IssueDate.ToShortDateString()</option>
} }
</select> </select>
</div> </div>

View File

@ -38,10 +38,10 @@
@foreach (var disease in Model) @foreach (var disease in Model)
{ {
<tr> <tr>
<td>@Html.DisplayFor(modelItem => disease.Id)</td> <th>@disease.Id</th>
<td>@Html.DisplayFor(modelItem => disease.Name)</td> <td>@disease.Name</td>
<td>@Html.DisplayFor(modelItem => disease.Symptoms)</td> <td>@disease.Symptoms</td>
<td>@Html.DisplayFor(modelItem => disease.RecipeId)</td> <td>@disease.RecipeId</td>
<td> <td>
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateDisease", "/Disease", new { id = disease.Id })'">Изменить</button></p> <p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateDisease", "/Disease", new { id = disease.Id })'">Изменить</button></p>
</td> </td>

View File

@ -31,7 +31,7 @@
@foreach (var recipe in ViewBag.Recipes) @foreach (var recipe in ViewBag.Recipes)
{ {
var isSelected = Model.RecipeId.Equals(recipe.Id); var isSelected = Model.RecipeId.Equals(recipe.Id);
<option value="@recipe.Id" selected="@isSelected">@recipe.Id - @recipe.IssueDate</option> <option value="@recipe.Id" selected="@isSelected">@recipe.Id - @recipe.IssueDate.ToShortDateString()</option>
} }
</select> </select>
</div> </div>

View File

@ -34,7 +34,7 @@
</div> </div>
<!-- Действия для отчета в формате Pdf --> <!-- Действия для отчета в формате Pdf -->
<div class="d-flex justify-content-around"> <div class="d-flex justify-content-between">
<!-- Сохранить отчет в формате Pdf --> <!-- Сохранить отчет в формате Pdf -->
<div class="text-center"> <div class="text-center">
<button type="submit" class="btn btn-primary" formaction="@Url.Action("CreateReportPdf", "Home")">Сведения о пациентах Pdf</button> <button type="submit" class="btn btn-primary" formaction="@Url.Action("CreateReportPdf", "Home")">Сведения о пациентах Pdf</button>

View File

@ -37,9 +37,9 @@
@foreach (var medicine in Model) @foreach (var medicine in Model)
{ {
<tr> <tr>
<td>@Html.DisplayFor(modelItem => medicine.Id)</td> <th>@medicine.Id</th>
<td>@Html.DisplayFor(modelItem => medicine.Name)</td> <td>@medicine.Name</td>
<td>@Html.DisplayFor(modelItem => medicine.Description)</td> <td>@medicine.Description</td>
<td> <td>
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateMedicine", "/Medicine", new { id = medicine.Id })'">Изменить</button></p> <p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateMedicine", "/Medicine", new { id = medicine.Id })'">Изменить</button></p>
</td> </td>

View File

@ -27,7 +27,7 @@
<select name="recipes" id="recipes" class="form-control" size="4" multiple> <select name="recipes" id="recipes" class="form-control" size="4" multiple>
@foreach (var recipe in ViewBag.Recipes) @foreach (var recipe in ViewBag.Recipes)
{ {
<option value="@recipe.Id">@recipe.Id - @recipe.IssueDate</option> <option value="@recipe.Id">@recipe.Id - @recipe.IssueDate.ToShortDateString()</option>
} }
</select> </select>
</div> </div>

View File

@ -39,11 +39,11 @@
@foreach (var patient in Model) @foreach (var patient in Model)
{ {
<tr> <tr>
<td>@Html.DisplayFor(modelItem => patient.Id)</td> <th>@patient.Id</th>
<td>@Html.DisplayFor(modelItem => patient.FullName)</td> <td>@patient.FullName</td>
<td>@Html.DisplayFor(modelItem => patient.BirthDate)</td> <td>@patient.BirthDate.ToShortDateString()</td>
<td>@Html.DisplayFor(modelItem => patient.Phone)</td> <td>@patient.Phone</td>
<td>@Html.DisplayFor(modelItem => patient.DoctorFullName)</td> <td>@patient.DoctorFullName</td>
<td> <td>
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdatePatient", "/Patient", new { id = patient.Id })'">Изменить</button></p> <p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdatePatient", "/Patient", new { id = patient.Id })'">Изменить</button></p>
</td> </td>

View File

@ -37,9 +37,9 @@
@foreach (var procedure in Model) @foreach (var procedure in Model)
{ {
<tr> <tr>
<td>@Html.DisplayFor(modelItem => procedure.Id)</td> <th>@procedure.Id</th>
<td>@Html.DisplayFor(modelItem => procedure.Name)</td> <td>@procedure.Name</td>
<td>@Html.DisplayFor(modelItem => procedure.Description)</td> <td>@procedure.Description</td>
<td> <td>
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateProcedure", "/Procedure", new { id = procedure.Id })'">Изменить</button></p> <p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateProcedure", "/Procedure", new { id = procedure.Id })'">Изменить</button></p>
</td> </td>

View File

@ -37,9 +37,9 @@
@foreach (var recipe in Model) @foreach (var recipe in Model)
{ {
<tr> <tr>
<td>@Html.DisplayFor(modelItem => recipe.Id)</td> <th>@recipe.Id</th>
<td>@Html.DisplayFor(modelItem => recipe.IssueDate)</td> <td>@recipe.IssueDate.ToShortDateString()</td>
<td>@Html.DisplayFor(modelItem => recipe.DoctorFullName)</td> <td>@recipe.DoctorFullName</td>
<td> <td>
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateRecipe", "/Recipe", new { id = recipe.Id })'">Изменить</button></p> <p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateRecipe", "/Recipe", new { id = recipe.Id })'">Изменить</button></p>
</td> </td>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" internalLogLevel="Info">
<targets>
<target xsi:type="File" name="tofile" fileName="D:\ULSTU\Семестр 4\РПП Coursework\Hospital\Logs/log-${shortdate}.log" />
</targets>
<rules>
<logger name="*" minLevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>