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)
*.userprefs
Reports
Logs
# Mono auto generated files
mono_crash.*

View File

@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace HospitalBusinessLogics.BusinessLogics
@ -159,9 +160,9 @@ namespace HospitalBusinessLogics.BusinessLogics
{
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))
{

View File

@ -34,5 +34,33 @@ namespace HospitalContracts.ViewModels
/// Идентификатор рецепта
/// </summary>
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>
[DisplayName("Описание лекарства")]
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;
set;
} = 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;
}
disease.Update(model);
disease.Update(context, model);
context.SaveChanges();
return disease.GetViewModel;
}

View File

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

View File

@ -294,7 +294,7 @@ namespace HospitalWebApp.Controllers
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
};

View File

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

View File

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

View File

@ -26,7 +26,7 @@
<select name="recipe" id="recipe" class="form-control">
@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>
</div>

View File

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

View File

@ -31,7 +31,7 @@
@foreach (var recipe in ViewBag.Recipes)
{
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>
</div>

View File

@ -34,7 +34,7 @@
</div>
<!-- Действия для отчета в формате Pdf -->
<div class="d-flex justify-content-around">
<div class="d-flex justify-content-between">
<!-- Сохранить отчет в формате Pdf -->
<div class="text-center">
<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)
{
<tr>
<td>@Html.DisplayFor(modelItem => medicine.Id)</td>
<td>@Html.DisplayFor(modelItem => medicine.Name)</td>
<td>@Html.DisplayFor(modelItem => medicine.Description)</td>
<th>@medicine.Id</th>
<td>@medicine.Name</td>
<td>@medicine.Description</td>
<td>
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateMedicine", "/Medicine", new { id = medicine.Id })'">Изменить</button></p>
</td>

View File

@ -27,7 +27,7 @@
<select name="recipes" id="recipes" class="form-control" size="4" multiple>
@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>
</div>

View File

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

View File

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

View File

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