WebApp / Redesigned the controllers without using RestAPI

This commit is contained in:
parent bcb3888c57
commit 1f59373622
36 changed files with 410 additions and 394 deletions

View File

@ -13,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalBusinessLogics", "H
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalWebApp", "HospitalWebApp\HospitalWebApp.csproj", "{024326F5-A7A5-41B5-9BEB-C1B10A533F23}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalRestApi", "HospitalRestApi\HospitalRestApi.csproj", "{D2449DB4-C819-44F4-8266-4B46CD8F15E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -41,10 +39,6 @@ Global
{024326F5-A7A5-41B5-9BEB-C1B10A533F23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{024326F5-A7A5-41B5-9BEB-C1B10A533F23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{024326F5-A7A5-41B5-9BEB-C1B10A533F23}.Release|Any CPU.Build.0 = Release|Any CPU
{D2449DB4-C819-44F4-8266-4B46CD8F15E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2449DB4-C819-44F4-8266-4B46CD8F15E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2449DB4-C819-44F4-8266-4B46CD8F15E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2449DB4-C819-44F4-8266-4B46CD8F15E2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -124,7 +124,7 @@ namespace HospitalDatabaseImplement.Implements
{
using var context = new HospitalDatabase();
var medicine = context.Medicines
.FirstOrDefault(x => x.Equals(model.Id));
.FirstOrDefault(x => x.Id.Equals(model.Id));
if (medicine == null)
{
return null;

View File

@ -148,7 +148,7 @@ namespace HospitalDatabaseImplement.Implements
var procedure = context.Procedures
.Include(x => x.Medicines)
.ThenInclude(x => x.Medicine)
.FirstOrDefault(x => x.Equals(model.Id));
.FirstOrDefault(x => x.Id.Equals(model.Id));
if (procedure == null)
{
return null;

View File

@ -154,7 +154,7 @@ namespace HospitalDatabaseImplement.Implements
.Include(x => x.Doctor)
.Include(x => x.Medicines)
.ThenInclude(x => x.Medicine)
.FirstOrDefault(x => x.Equals(model.Id));
.FirstOrDefault(x => x.Id.Equals(model.Id));
if (recipe == null)
{
return null;

View File

@ -190,7 +190,12 @@ namespace HospitalDatabaseImplement.Models
var patient = context.Patients.First(x => x.Id == Id);
foreach (var pr in model.PatientRecipes)
{
context.PatientRecipes.Add(new PatientRecipe
if (patientRecipes!.Any(x => x.RecipeId == pr.Key))
{
continue;
}
context.PatientRecipes.Add(new PatientRecipe
{
Patient = patient,
Recipe = context.Recipes.First(x => x.Id == pr.Key)
@ -218,7 +223,12 @@ namespace HospitalDatabaseImplement.Models
var patient = context.Patients.First(x => x.Id == Id);
foreach (var pp in model.PatientProcedures)
{
context.PatientProcedures.Add(new PatientProcedure
if (patientProcedures!.Any(x => x.ProcedureId == pp.Key))
{
continue;
}
context.PatientProcedures.Add(new PatientProcedure
{
Patient = patient,
Procedure = context.Procedures.First(x => x.Id == pp.Key)

View File

@ -131,6 +131,11 @@ namespace HospitalDatabaseImplement.Models
var procedure = context.Procedures.First(x => x.Id == Id);
foreach (var pm in model.ProcedureMedicines)
{
if (procedureMedicines!.Any(x => x.MedicineId == pm.Key))
{
continue;
}
context.ProcedureMedicines.Add(new ProcedureMedicine
{
Procedure = procedure,

View File

@ -137,7 +137,12 @@ namespace HospitalDatabaseImplement.Models
var recipe = context.Recipes.First(x => x.Id == Id);
foreach (var rm in model.RecipeMedicines)
{
context.RecipeMedicines.Add(new RecipeMedicine
if (recipeMedicines!.Any(x => x.MedicineId == rm.Key))
{
continue;
}
context.RecipeMedicines.Add(new RecipeMedicine
{
Recipe = recipe,
Medicine = context.Medicines.First(x => x.Id == rm.Key)

View File

@ -1,33 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace HospitalRestApi.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

View File

@ -1,23 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HospitalBusinessLogics\HospitalBusinessLogics.csproj" />
<ProjectReference Include="..\HospitalDatabaseImplement\HospitalDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -1,61 +0,0 @@
using HospitalBusinessLogics.BusinessLogics;
using HospitalBusinessLogics.OfficePackage.Implements;
using HospitalBusinessLogics.OfficePackage;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.StoragesContracts;
using HospitalDatabaseImplement.Implements;
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Logger service
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddLog4Net("log4net.config");
// Storage services
builder.Services.AddTransient<IDoctorStorage, DoctorStorage>();
builder.Services.AddTransient<IPatientStorage, PatientStorage>();
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
builder.Services.AddTransient<IDiseaseStorage, DiseaseStorage>();
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
builder.Services.AddTransient<IMedicineStorage, MedicineStorage>();
// BusinessLogic services
builder.Services.AddTransient<IDoctorLogic, DoctorLogic>();
builder.Services.AddTransient<IPatientLogic, PatientLogic>();
builder.Services.AddTransient<IRecipeLogic, RecipeLogic>();
builder.Services.AddTransient<IDiseaseLogic, DiseaseLogic>();
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
builder.Services.AddTransient<IMedicineLogic, MedicineLogic>();
// BusinessLogic Reports services
builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "HospitalRestApi", Version = "v1" });
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "HospitalRestApi v1"));
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -1,31 +0,0 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:20442",
"sslPort": 44332
}
},
"profiles": {
"HospitalRestApi": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7267;http://localhost:5235",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -1,13 +0,0 @@
namespace HospitalRestApi
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

View File

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -1,9 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

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

@ -1,7 +1,4 @@
using HospitalContracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace HospitalWebApp
{
@ -10,68 +7,9 @@ namespace HospitalWebApp
/// </summary>
public static class APIClient
{
/// <summary>
/// Http-клиент
/// </summary>
private static readonly HttpClient _client = new();
/// <summary>
/// Авторизованный доктор
/// </summary>
public static DoctorViewModel? Doctor { get; set; } = null;
/// <summary>
/// Подключение
/// </summary>
/// <param name="configuration"></param>
public static void Connect(IConfiguration configuration)
{
_client.BaseAddress = new Uri(configuration["IPAddress"]);
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
/// <summary>
/// Get-запрос
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="requestUrl"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static T? GetRequest<T>(string requestUrl)
{
var response = _client.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<T>(result);
}
else
{
throw new Exception(result);
}
}
/// <summary>
/// Post-запрос
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="requestUrl"></param>
/// <param name="model"></param>
/// <exception cref="Exception"></exception>
public static void PostRequest<T>(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);
}
}
}
}

View File

@ -1,4 +1,6 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using Microsoft.AspNetCore.Mvc;
@ -15,13 +17,27 @@ namespace HospitalWebApp.Controllers
/// </summary>
private readonly ILogger<DiseaseController> _logger;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="logger"></param>
public DiseaseController(ILogger<DiseaseController> logger)
/// <summary>
/// Бизнес-логика для сущности "Болезнь"
/// </summary>
private readonly IDiseaseLogic _diseaseLogic;
/// <summary>
/// Бизнес-логика для сущности "Рецепт"
/// </summary>
private readonly IRecipeLogic _recipeLogic;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="logger"></param>
/// <param name="diseaseLogic"></param>
/// <param name="recipeLogic"></param>
public DiseaseController(ILogger<DiseaseController> logger, IDiseaseLogic diseaseLogic, IRecipeLogic recipeLogic)
{
_logger = logger;
_diseaseLogic = diseaseLogic;
_recipeLogic = recipeLogic;
}
/// <summary>
@ -36,7 +52,7 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases"));
return View(_diseaseLogic.ReadList(null));
}
/// <summary>
@ -51,7 +67,11 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipes?doctorId={APIClient.Doctor.Id}");
ViewBag.Recipes = _recipeLogic.ReadList(new RecipeSearchModel
{
DoctorId = APIClient.Doctor.Id,
});
return View();
}
@ -63,27 +83,27 @@ namespace HospitalWebApp.Controllers
/// <param name="recipeId"></param>
/// <exception cref="Exception"></exception>
[HttpPost]
public void CreateDisease(string name, string? symptoms, int recipeId)
public void CreateDisease(string name, string? symptoms, int recipe)
{
if (APIClient.Doctor == null)
{
throw new Exception("Необходимо авторизоваться!");
}
if (string.IsNullOrEmpty(name) || recipeId <= 0)
if (string.IsNullOrEmpty(name) || recipe <= 0)
{
throw new Exception("Введены не все данные!");
}
APIClient.PostRequest("api/disease/createdisease", new DiseaseBindingModel
_diseaseLogic.Create(new DiseaseBindingModel
{
Name = name,
Symptoms = symptoms,
RecipeId = recipeId
RecipeId = recipe
});
Response.Redirect("Diseases");
}
Response.Redirect("/Disease/Diseases");
}
/// <summary>
/// Редактировать болезнь
@ -97,8 +117,15 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipes?doctorId={APIClient.Doctor.Id}");
return View(APIClient.GetRequest<DiseaseViewModel>($"api/disease/getdisease?id={id}"));
ViewBag.Recipes = _recipeLogic.ReadList(new RecipeSearchModel
{
DoctorId = APIClient.Doctor.Id,
});
return View(_diseaseLogic.ReadElement(new DiseaseSearchModel
{
Id = id
}));
}
/// <summary>
@ -110,28 +137,28 @@ namespace HospitalWebApp.Controllers
/// <param name="recipeId"></param>
/// <exception cref="Exception"></exception>
[HttpPost]
public void UpdateDisease(int id, string name, string? symptoms, int recipeId)
public void UpdateDisease(int id, string name, string? symptoms, int recipe)
{
if (APIClient.Doctor == null)
{
throw new Exception("Необходимо авторизоваться!");
}
if (string.IsNullOrEmpty(name) || recipeId <= 0)
if (string.IsNullOrEmpty(name) || recipe <= 0)
{
throw new Exception("Введены не все данные!");
}
APIClient.PostRequest("api/disease/updatedisease", new DiseaseBindingModel
_diseaseLogic.Update(new DiseaseBindingModel
{
Id = id,
Name = name,
Symptoms = symptoms,
RecipeId = recipeId
RecipeId = recipe
});
Response.Redirect("Diseases");
}
Response.Redirect("/Disease/Diseases");
}
/// <summary>
/// Удалить болезнь
@ -145,12 +172,12 @@ namespace HospitalWebApp.Controllers
throw new Exception("Необходимо авторизоваться!");
}
APIClient.PostRequest($"api/disease/deletedisease", new DiseaseBindingModel
_diseaseLogic.Delete(new DiseaseBindingModel
{
Id = id
});
Response.Redirect("Diseases");
}
Response.Redirect("/Disease/Diseases");
}
}
}

View File

@ -1,4 +1,6 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Enums;
using HospitalWebApp.Models;
@ -17,13 +19,20 @@ namespace HospitalWebApp.Controllers
/// </summary>
private readonly ILogger<HomeController> _logger;
/// <summary>
/// Бизнес-логика для сущности "Доктор"
/// </summary>
private readonly IDoctorLogic _doctorLogic;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="logger"></param>
public HomeController(ILogger<HomeController> logger)
/// <param name="doctorLogic"></param>
public HomeController(ILogger<HomeController> logger, IDoctorLogic doctorLogic)
{
_logger = logger;
_doctorLogic = doctorLogic;
}
/// <summary>
@ -31,7 +40,7 @@ namespace HospitalWebApp.Controllers
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult MainPage()
public IActionResult Index()
{
if (APIClient.Doctor == null)
{
@ -77,7 +86,7 @@ namespace HospitalWebApp.Controllers
throw new Exception("Введены не все данные!");
}
APIClient.PostRequest("api/doctor/update", new DoctorBindingModel
_doctorLogic.Update(new DoctorBindingModel
{
Id = APIClient.Doctor.Id,
FullName = fullname,
@ -101,6 +110,11 @@ namespace HospitalWebApp.Controllers
[HttpGet]
public IActionResult Enter()
{
if (APIClient.Doctor != null)
{
throw new Exception("Вы уже авторизовались!");
}
return View();
}
@ -118,13 +132,17 @@ namespace HospitalWebApp.Controllers
throw new Exception("Введены не все данные!");
}
APIClient.Doctor = APIClient.GetRequest<DoctorViewModel>($"api/doctor/login?email={email}&password={password}");
APIClient.Doctor = _doctorLogic.ReadElement(new DoctorSearchModel
{
Email = email,
Password = password
});
if (APIClient.Doctor == null)
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("MainPage");
Response.Redirect("Index");
}
/// <summary>
@ -134,6 +152,11 @@ namespace HospitalWebApp.Controllers
[HttpGet]
public IActionResult Register()
{
if (APIClient.Doctor != null)
{
throw new Exception("Вы уже зарегистрировались!");
}
return View();
}
@ -153,7 +176,7 @@ namespace HospitalWebApp.Controllers
throw new Exception("Введены не все данные!");
}
APIClient.PostRequest("api/doctor/register", new DoctorBindingModel
_doctorLogic.Create(new DoctorBindingModel
{
FullName = fullname,
Post = post,
@ -164,6 +187,22 @@ namespace HospitalWebApp.Controllers
Response.Redirect("Enter");
}
/// <summary>
/// Выйти из аккаунта
/// </summary>
/// <exception cref="Exception"></exception>
[HttpGet]
public void Logout()
{
if (APIClient.Doctor == null)
{
throw new Exception("Необходимо авторизоваться!");
}
APIClient.Doctor = null;
Response.Redirect("Enter");
}
/// <summary>
/// Ошибка
/// </summary>

View File

@ -1,6 +1,7 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using Microsoft.AspNetCore.Mvc;
namespace HospitalWebApp.Controllers
@ -16,12 +17,19 @@ namespace HospitalWebApp.Controllers
private readonly ILogger<MedicineController> _logger;
/// <summary>
/// Конструктор
/// Бизнес-логика для сущности "Лекарство"
/// </summary>
/// <param name="logger"></param>
public MedicineController(ILogger<MedicineController> logger)
private readonly IMedicineLogic _medicineLogic;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="logger"></param>
/// <param name="medicineLogic"></param>
public MedicineController(ILogger<MedicineController> logger, IMedicineLogic medicineLogic)
{
_logger = logger;
_medicineLogic = medicineLogic;
}
/// <summary>
@ -36,7 +44,7 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines"));
return View(_medicineLogic.ReadList(null));
}
/// <summary>
@ -73,14 +81,14 @@ namespace HospitalWebApp.Controllers
throw new Exception("Введены не все данные!");
}
APIClient.PostRequest("api/medicine/createmedicine", new MedicineBindingModel
_medicineLogic.Create(new MedicineBindingModel
{
Name = name,
Description = description
});
Response.Redirect("Medicines");
}
Response.Redirect("/Medicine/Medicines");
}
/// <summary>
/// Редактировать лекарство
@ -94,7 +102,10 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<MedicineViewModel>($"api/medicine/getmedicine?id={id}"));
return View(_medicineLogic.ReadElement(new MedicineSearchModel
{
Id = id
}));
}
/// <summary>
@ -116,14 +127,14 @@ namespace HospitalWebApp.Controllers
throw new Exception("Введены не все данные!");
}
APIClient.PostRequest("api/medicine/updatemedicine", new MedicineBindingModel
_medicineLogic.Update(new MedicineBindingModel
{
Id = id,
Name = name,
Description = description
});
Response.Redirect("Medicines");
Response.Redirect("/Medicine/Medicines");
}
/// <summary>
@ -138,12 +149,12 @@ namespace HospitalWebApp.Controllers
throw new Exception("Необходимо авторизоваться!");
}
APIClient.PostRequest($"api/medicine/deletemedicine", new MedicineBindingModel
_medicineLogic.Delete(new MedicineBindingModel
{
Id = id
});
Response.Redirect("Medicines");
}
Response.Redirect("/Medicine/Medicines");
}
}
}

View File

@ -1,5 +1,7 @@
using HospitalContracts.BindingModels;
using DocumentFormat.OpenXml.Office2010.Excel;
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using Microsoft.AspNetCore.Mvc;
@ -17,13 +19,34 @@ namespace HospitalWebApp.Controllers
/// </summary>
private readonly ILogger<PatientController> _logger;
/// <summary>
/// Бизнес-логика для сущности "Пациент"
/// </summary>
private readonly IPatientLogic _patientLogic;
/// <summary>
/// Бизнес-логика для сущности "Рецепт"
/// </summary>
private readonly IRecipeLogic _recipeLogic;
/// <summary>
/// Бизнес-логика для сущности "Процедура"
/// </summary>
private readonly IProcedureLogic _procedureLogic;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="logger"></param>
public PatientController(ILogger<PatientController> logger)
/// <param name="patientLogic"></param>
/// <param name="recipeLogic"></param>
/// <param name="procedureLogic"></param>
public PatientController(ILogger<PatientController> logger, IPatientLogic patientLogic, IRecipeLogic recipeLogic, IProcedureLogic procedureLogic)
{
_logger = logger;
_patientLogic = patientLogic;
_recipeLogic = recipeLogic;
_procedureLogic = procedureLogic;
}
/// <summary>
@ -38,7 +61,10 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<PatientViewModel>>($"api/patient/getpatients?doctorId={APIClient.Doctor.Id}"));
return View(_patientLogic.ReadList(new PatientSearchModel
{
DoctorId = APIClient.Doctor.Id,
}));
}
/// <summary>
@ -53,7 +79,8 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Procedures = APIClient.GetRequest<List<ProcedureViewModel>>("api/procedure/getprocedures");
ViewBag.Procedures = _procedureLogic.ReadList(null);
return View();
}
@ -81,10 +108,10 @@ namespace HospitalWebApp.Controllers
Dictionary<int, IProcedureModel> patientProcedures = new Dictionary<int, IProcedureModel>();
foreach (var procedureId in procedures)
{
patientProcedures.Add(procedureId, APIClient.GetRequest<ProcedureViewModel>($"api/procedure/getprocedure?id={procedureId}"));
patientProcedures.Add(procedureId, _procedureLogic.ReadElement(new ProcedureSearchModel { Id = procedureId })!);
}
APIClient.PostRequest("api/patient/createpatient", new PatientBindingModel
_patientLogic.Create(new PatientBindingModel
{
FullName = fullname,
BirthDate = birthdate,
@ -93,7 +120,7 @@ namespace HospitalWebApp.Controllers
PatientProcedures = patientProcedures
});
Response.Redirect("Patients");
Response.Redirect("/Patient/Patients");
}
/// <summary>
@ -108,8 +135,12 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Procedures = APIClient.GetRequest<List<ProcedureViewModel>>("api/procedure/getprocedures");
return View(APIClient.GetRequest<PatientViewModel>($"api/patient/getpatient?id={id}"));
ViewBag.Procedures = _procedureLogic.ReadList(null);
return View(_patientLogic.ReadElement(new PatientSearchModel
{
Id = id
}));
}
/// <summary>
@ -136,20 +167,22 @@ namespace HospitalWebApp.Controllers
Dictionary<int, IProcedureModel> patientProcedures = new Dictionary<int, IProcedureModel>();
foreach (var procedureId in procedures)
{
patientProcedures.Add(procedureId, APIClient.GetRequest<ProcedureViewModel>($"api/procedure/getprocedure?id={procedureId}"));
patientProcedures.Add(procedureId, _procedureLogic.ReadElement(new ProcedureSearchModel { Id = procedureId })!);
}
APIClient.PostRequest("api/patient/updatepatient", new PatientBindingModel
var patient = _patientLogic.ReadElement(new PatientSearchModel { Id = id });
_patientLogic.Update(new PatientBindingModel
{
Id = id,
FullName = fullname,
BirthDate = birthdate,
Phone = phone,
DoctorId = APIClient.Doctor.Id,
PatientRecipes = patient!.PatientRecipes,
PatientProcedures = patientProcedures
});
Response.Redirect("Patients");
Response.Redirect("/Patient/Patients");
}
/// <summary>
@ -164,12 +197,12 @@ namespace HospitalWebApp.Controllers
throw new Exception("Необходимо авторизоваться!");
}
APIClient.PostRequest($"api/patient/deletepatient", new PatientBindingModel
_patientLogic.Delete(new PatientBindingModel
{
Id = id
});
Response.Redirect("Patients");
Response.Redirect("/Patient/Patients");
}
/// <summary>
@ -185,8 +218,15 @@ namespace HospitalWebApp.Controllers
throw new Exception("Необходимо авторизоваться!");
}
ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>($"api/patient/getpatients?doctorId={APIClient.Doctor.Id}");
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipes?doctorId={APIClient.Doctor.Id}");
ViewBag.Patients = _patientLogic.ReadList(new PatientSearchModel
{
DoctorId = APIClient.Doctor.Id
});
ViewBag.Recipes = _recipeLogic.ReadList(new RecipeSearchModel
{
DoctorId = APIClient.Doctor.Id
});
return View();
}
@ -212,11 +252,11 @@ namespace HospitalWebApp.Controllers
Dictionary<int, IRecipeModel> patientRecipes = new Dictionary<int, IRecipeModel>();
foreach (var recipeId in recipes)
{
patientRecipes.Add(recipeId, APIClient.GetRequest<RecipeViewModel>($"api/recipe/getrecipe?id={recipeId}"));
patientRecipes.Add(recipeId, _recipeLogic.ReadElement(new RecipeSearchModel { Id = recipeId })!);
}
var patient = APIClient.GetRequest<PatientViewModel>($"api/patient/getpatient?id={patientId}");
APIClient.PostRequest("api/patient/updatepatient", new PatientBindingModel
var patient = _patientLogic.ReadElement(new PatientSearchModel { Id = patientId });
_patientLogic.Update(new PatientBindingModel
{
Id = patient!.Id,
FullName = patient!.FullName,
@ -227,7 +267,38 @@ namespace HospitalWebApp.Controllers
PatientRecipes = patientRecipes
});
Response.Redirect("Patients");
Response.Redirect("/Patient/Patients");
}
/// <summary>
/// Получить список рецептов пациента
/// </summary>
/// <param name="patientId"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
[HttpGet]
public JsonResult GetPatientRecipes(int patientId)
{
if (APIClient.Doctor == null)
{
throw new Exception("Необходимо авторизоваться!");
}
var allRecipes = _recipeLogic.ReadList(new RecipeSearchModel
{
DoctorId = APIClient.Doctor.Id
});
var patient = _patientLogic.ReadElement(new PatientSearchModel { Id = patientId });
var patientRecipeIds = patient?.PatientRecipes?.Select(x => x.Key).ToList() ?? new List<int>();
var result = new
{
allRecipes = allRecipes.Select(r => new { id = r.Id, issueDate = r.IssueDate }),
patientRecipeIds = patientRecipeIds
};
return Json(result);
}
}
}

View File

@ -1,4 +1,6 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using Microsoft.AspNetCore.Mvc;
@ -15,13 +17,27 @@ namespace HospitalWebApp.Controllers
/// </summary>
private readonly ILogger<ProcedureController> _logger;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="logger"></param>
public ProcedureController(ILogger<ProcedureController> logger)
/// <summary>
/// Бизнес-логика для сущности "Процедура"
/// </summary>
private readonly IProcedureLogic _procedureLogic;
/// <summary>
/// Бизнес-логика для сущности "Лекарство"
/// </summary>
private readonly IMedicineLogic _medicineLogic;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="logger"></param>
/// <param name="procedureLogic"></param>
/// <param name="medicineLogic"></param>
public ProcedureController(ILogger<ProcedureController> logger, IProcedureLogic procedureLogic, IMedicineLogic medicineLogic)
{
_logger = logger;
_procedureLogic = procedureLogic;
_medicineLogic = medicineLogic;
}
/// <summary>
@ -36,7 +52,7 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures"));
return View(_procedureLogic.ReadList(null));
}
/// <summary>
@ -51,7 +67,7 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Medicines = APIClient.GetRequest<List<MedicineViewModel>>("api/medicine/getmedicines");
ViewBag.Medicines = _medicineLogic.ReadList(null);
return View();
}
@ -78,17 +94,17 @@ namespace HospitalWebApp.Controllers
Dictionary<int, IMedicineModel> procedureMedicines = new Dictionary<int, IMedicineModel>();
foreach (var medicineId in medicines)
{
procedureMedicines.Add(medicineId, APIClient.GetRequest<MedicineViewModel>($"api/medicine/getmedicine?id={medicineId}"));
procedureMedicines.Add(medicineId, _medicineLogic.ReadElement(new MedicineSearchModel { Id = medicineId })!);
}
APIClient.PostRequest("api/procedure/createprocedure", new ProcedureBindingModel
_procedureLogic.Create(new ProcedureBindingModel
{
Name = name,
Description = description,
ProcedureMedicines = procedureMedicines
});
Response.Redirect("Procedures");
Response.Redirect("/Procedure/Procedures");
}
/// <summary>
@ -103,8 +119,12 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Medicines = APIClient.GetRequest<List<MedicineViewModel>>("api/medicine/getmedicines");
return View(APIClient.GetRequest<ProcedureViewModel>($"api/procedure/getprocedure?id={id}"));
ViewBag.Medicines = _medicineLogic.ReadList(null);
return View(_procedureLogic.ReadElement(new ProcedureSearchModel
{
Id = id
}));
}
/// <summary>
@ -127,22 +147,22 @@ namespace HospitalWebApp.Controllers
throw new Exception("Введены не все данные!");
}
Dictionary<int, IMedicineModel> procedureMedicines = new Dictionary<int, IMedicineModel>();
foreach (var medicineId in medicines)
{
procedureMedicines.Add(medicineId, APIClient.GetRequest<MedicineViewModel>($"api/medicine/getmedicine?id={medicineId}"));
}
Dictionary<int, IMedicineModel> procedureMedicines = new Dictionary<int, IMedicineModel>();
foreach (var medicineId in medicines)
{
procedureMedicines.Add(medicineId, _medicineLogic.ReadElement(new MedicineSearchModel { Id = medicineId })!);
}
APIClient.PostRequest("api/procedure/updateprocedure", new ProcedureBindingModel
{
_procedureLogic.Update(new ProcedureBindingModel
{
Id = id,
Name = name,
Description = description,
ProcedureMedicines = procedureMedicines
});
Name = name,
Description = description,
ProcedureMedicines = procedureMedicines
});
Response.Redirect("Procedures");
}
Response.Redirect("/Procedure/Procedures");
}
/// <summary>
/// Удалить процедуру
@ -156,12 +176,12 @@ namespace HospitalWebApp.Controllers
throw new Exception("Необходимо авторизоваться!");
}
APIClient.PostRequest($"api/procedure/deleteprocedure", new ProcedureBindingModel
_procedureLogic.Delete(new ProcedureBindingModel
{
Id = id
});
Response.Redirect("Prodecures");
}
Response.Redirect("/Procedure/Procedures");
}
}
}

View File

@ -1,4 +1,6 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using Microsoft.AspNetCore.Mvc;
@ -16,13 +18,28 @@ namespace HospitalWebApp.Controllers
/// </summary>
private readonly ILogger<RecipeController> _logger;
/// <summary>
/// Бизнес-логика для сущности "Рецепт"
/// </summary>
private readonly IRecipeLogic _recipeLogic;
/// <summary>
/// Бизнес-логика для сущности "Лекарство"
/// </summary>
private readonly IMedicineLogic _medicineLogic;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="logger"></param>
public RecipeController(ILogger<RecipeController> logger)
/// <param name="recipeLogic"></param>
/// <param name="medicineLogic"></param>
public RecipeController(ILogger<RecipeController> logger, IRecipeLogic recipeLogic, IMedicineLogic medicineLogic)
{
_logger = logger;
_recipeLogic = recipeLogic;
_medicineLogic = medicineLogic;
}
/// <summary>
@ -37,7 +54,10 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipes?doctorId={APIClient.Doctor.Id}"));
return View(_recipeLogic.ReadList(new RecipeSearchModel
{
DoctorId = APIClient.Doctor.Id,
}));
}
/// <summary>
@ -52,7 +72,7 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Medicines = APIClient.GetRequest<List<MedicineViewModel>>("api/medicine/getmedicines");
ViewBag.Medicines = _medicineLogic.ReadList(null);
return View();
}
@ -78,17 +98,17 @@ namespace HospitalWebApp.Controllers
Dictionary<int, IMedicineModel> recipeMedicines = new Dictionary<int, IMedicineModel>();
foreach (var medicineId in medicines)
{
recipeMedicines.Add(medicineId, APIClient.GetRequest<MedicineViewModel>($"api/medicine/getmedicine?id={medicineId}"));
recipeMedicines.Add(medicineId, _medicineLogic.ReadElement(new MedicineSearchModel { Id = medicineId })!);
}
APIClient.PostRequest("api/recipe/createrecipe", new RecipeBindingModel
_recipeLogic.Create(new RecipeBindingModel
{
IssueDate = issuedate,
DoctorId = APIClient.Doctor.Id,
RecipeMedicines = recipeMedicines
});
Response.Redirect("Recipes");
Response.Redirect("/Recipe/Recipes");
}
/// <summary>
@ -103,8 +123,12 @@ namespace HospitalWebApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Medicines = APIClient.GetRequest<List<MedicineViewModel>>("api/medicine/getmedicines");
return View(APIClient.GetRequest<PatientViewModel>($"api/patient/getpatient?id={id}"));
ViewBag.Medicines = _medicineLogic.ReadList(null);
return View(_recipeLogic.ReadElement(new RecipeSearchModel
{
Id = id
}));
}
/// <summary>
@ -130,10 +154,10 @@ namespace HospitalWebApp.Controllers
Dictionary<int, IMedicineModel> recipeMedicines = new Dictionary<int, IMedicineModel>();
foreach (var medicineId in medicines)
{
recipeMedicines.Add(medicineId, APIClient.GetRequest<MedicineViewModel>($"api/medicine/getmedicine?id={medicineId}"));
recipeMedicines.Add(medicineId, _medicineLogic.ReadElement(new MedicineSearchModel { Id = medicineId })!);
}
APIClient.PostRequest("api/recipe/updaterecipe", new RecipeBindingModel
_recipeLogic.Update(new RecipeBindingModel
{
Id = id,
IssueDate = issuedate,
@ -141,7 +165,7 @@ namespace HospitalWebApp.Controllers
RecipeMedicines = recipeMedicines
});
Response.Redirect("Recipes");
Response.Redirect("/Recipe/Recipes");
}
/// <summary>
@ -156,12 +180,12 @@ namespace HospitalWebApp.Controllers
throw new Exception("Необходимо авторизоваться!");
}
APIClient.PostRequest($"api/recipe/deleterecipe", new RecipeBindingModel
_recipeLogic.Delete(new RecipeBindingModel
{
Id = id
});
Response.Redirect("Recipes");
Response.Redirect("/Recipe/Recipes");
}
}
}

View File

@ -11,7 +11,9 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HospitalBusinessLogics\HospitalBusinessLogics.csproj" />
<ProjectReference Include="..\HospitalContracts\HospitalContracts.csproj" />
<ProjectReference Include="..\HospitalDatabaseImplement\HospitalDatabaseImplement.csproj" />
<ProjectReference Include="..\HospitalDataModels\HospitalDataModels.csproj" />
</ItemGroup>

View File

@ -1,3 +1,9 @@
using HospitalBusinessLogics.BusinessLogics;
using HospitalBusinessLogics.OfficePackage;
using HospitalBusinessLogics.OfficePackage.Implements;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.StoragesContracts;
using HospitalDatabaseImplement.Implements;
using HospitalWebApp;
var builder = WebApplication.CreateBuilder(args);
@ -5,9 +11,29 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
// Storage services
builder.Services.AddTransient<IDoctorStorage, DoctorStorage>();
builder.Services.AddTransient<IPatientStorage, PatientStorage>();
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
builder.Services.AddTransient<IDiseaseStorage, DiseaseStorage>();
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
builder.Services.AddTransient<IMedicineStorage, MedicineStorage>();
APIClient.Connect(builder.Configuration);
// BusinessLogic services
builder.Services.AddTransient<IDoctorLogic, DoctorLogic>();
builder.Services.AddTransient<IPatientLogic, PatientLogic>();
builder.Services.AddTransient<IRecipeLogic, RecipeLogic>();
builder.Services.AddTransient<IDiseaseLogic, DiseaseLogic>();
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
builder.Services.AddTransient<IMedicineLogic, MedicineLogic>();
// BusinessLogic Reports services
builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())

View File

@ -29,6 +29,8 @@
<th>Название</th>
<th>Симптомы</th>
<th>Номер рецепта</th>
<th>Изменить</th>
<th>Удалить</th>
</tr>
</thead>

View File

@ -23,11 +23,11 @@
<div class="col-4">Должность:</div>
<div class="col-8">
<select name="post">
<option id="@DoctorPost.Главный_врач" value="@DoctorPost.Главный_врач" selected="@(Model.Post == DoctorPost.Главный_врач ? "selected" : "")">Главный врач</option>
<option id="@DoctorPost.Терапевт" value="@DoctorPost.Терапевт" selected="@(Model.Post == DoctorPost.Терапевт ? "selected" : "")">Терапевт</option>
<option id="@DoctorPost.Педиатр" value="@DoctorPost.Педиатр" selected="@(Model.Post == DoctorPost.Педиатр ? "selected" : "")">Педиатр</option>
<option id="@DoctorPost.Медсестра" value="@DoctorPost.Медсестра" selected="@(Model.Post == DoctorPost.Медсестра ? "selected" : "")">Медсестра</option>
<option id="@DoctorPost.Медбрат" value="@DoctorPost.Медбрат" selected="@(Model.Post == DoctorPost.Медбрат ? "selected" : "")">Медбрат</option>
@foreach (DoctorPost post in Enum.GetValues(typeof(DoctorPost)))
{
var isSelected = Model.Post == post;
<option value="@post" selected="@isSelected">@post</option>
}
</select>
</div>
</div>

View File

@ -28,6 +28,8 @@
<th>Номер</th>
<th>Название</th>
<th>Описание</th>
<th>Изменить</th>
<th>Удалить</th>
</tr>
</thead>

View File

@ -11,7 +11,7 @@
<div class="row">
<div class="col-4">Пациенты:</div>
<div class="col-8">
<select name="patientId" id="patientId" class="form-control">
<select name="patientId" id="patientId" class="form-control" onchange="loadPatientRecipes()">
@foreach (var patient in ViewBag.Patients)
{
<option value="@patient.Id">@patient.FullName</option>
@ -39,3 +39,27 @@
<div class="col-4"><input type="submit" value="Выписать" class="btn btn-primary" /></div>
</div>
</form>
<!-- Загрузка выписанных ранее рецептов пациента -->
<script>
function loadPatientRecipes() {
var patientId = document.getElementById("patientId").value;
if (patientId) {
fetch('/Patient/GetPatientRecipes?patientId=' + patientId)
.then(response => response.json())
.then(data => {
var recipeSelect = document.getElementById("recipes");
recipeSelect.innerHTML = '';
data.allRecipes.forEach(function (recipe) {
var option = document.createElement("option");
option.value = recipe.id;
option.text = recipe.id + ' - ' + recipe.issueDate;
if (data.patientRecipeIds.includes(recipe.id)) {
option.selected = true;
}
recipeSelect.appendChild(option);
});
});
}
}
</script>

View File

@ -30,6 +30,8 @@
<th>Дата рождения</th>
<th>Номер телефона</th>
<th>Лечащий врач</th>
<th>Изменить</th>
<th>Удалить</th>
</tr>
</thead>
@ -39,7 +41,7 @@
<tr>
<td>@Html.DisplayFor(modelItem => patient.Id)</td>
<td>@Html.DisplayFor(modelItem => patient.FullName)</td>
<td>@Html.DisplayFor(modelItem => patient.BirthDate.ToShortDateString())</td>
<td>@Html.DisplayFor(modelItem => patient.BirthDate)</td>
<td>@Html.DisplayFor(modelItem => patient.Phone)</td>
<td>@Html.DisplayFor(modelItem => patient.DoctorFullName)</td>
<td>

View File

@ -20,7 +20,7 @@
<!-- Дата рождения -->
<div class="row">
<div class="col-4">Дата рождения:</div>
<div class="col-8"><input type="date" class="form-control" name="birthdate" value="@Model.BirthDate.ToShortDateString()" /></div>
<div class="col-8"><input type="date" class="form-control" name="birthdate" value="@Model.BirthDate.ToString("yyyy-MM-dd")" /></div>
</div>
<!-- Номер телефона -->

View File

@ -28,6 +28,8 @@
<th>Номер</th>
<th>Название</th>
<th>Описание</th>
<th>Изменить</th>
<th>Удалить</th>
</tr>
</thead>

View File

@ -28,6 +28,8 @@
<th>Номер</th>
<th>Дата выписки</th>
<th>Доктор</th>
<th>Изменить</th>
<th>Удалить</th>
</tr>
</thead>
@ -36,7 +38,7 @@
{
<tr>
<td>@Html.DisplayFor(modelItem => recipe.Id)</td>
<td>@Html.DisplayFor(modelItem => recipe.IssueDate.ToShortDateString())</td>
<td>@Html.DisplayFor(modelItem => recipe.IssueDate)</td>
<td>@Html.DisplayFor(modelItem => 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>
@ -53,7 +55,7 @@
@section scripts {
<script>
function deletePatient(id) {
function deleteRecipe(id) {
if (confirm("Вы уверены, что хотите удалить рецепт?")) {
$.post('@Url.Action("DeleteRecipe", "/Recipe")' + '/' + id, function () {
window.location.reload();

View File

@ -14,7 +14,7 @@
<!-- Дата выписки -->
<div class="row">
<div class="col-4">Дата выписки:</div>
<div class="col-8"><input type="date" class="form-control" name="issuedate" value="@Model.IssueDate.ToShortDateString()" /></div>
<div class="col-8"><input type="date" class="form-control" name="issuedate" value="@Model.IssueDate.ToString("yyyy-MM-dd")" /></div>
</div>
<!-- Лекарства -->

View File

@ -13,7 +13,7 @@
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<!-- Логотип и название -->
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="MainPage">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">
<img src="~/logo.jpg" alt="logo" style="max-height: 40px;"/>
Будьте больны!
</a>
@ -21,8 +21,8 @@
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<ul class="navbar-nav flex-grow-1">
<div class="navbar-collapse collapse d-sm-inline-flex">
<ul class="navbar-nav me-auto">
<!-- Пациенты -->
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Patient" asp-action="Patients">Пациенты</a>
@ -45,12 +45,14 @@
</li>
<!-- Выписка рецептов (привязка рецептов к пациентам) -->
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Recipe" asp-action="CreatePatientRecipe">Выписать рецепт</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Patient" asp-action="CreatePatientRecipe">Выписать рецепт</a>
</li>
<!-- Отчеты -->
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Reports">Отчеты</a>
</li>
</ul>
<ul class="navbar-nav ms-auto">
<!-- Личные данные -->
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
@ -63,6 +65,10 @@
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li>
<!-- Выход -->
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выход</a>
</li>
</ul>
</div>
</div>

View File

@ -5,7 +5,5 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"IPAddress": "http://localhost:5235"
"AllowedHosts": "*"
}