добавление контроллеров в рест апи приложение для рабоника
This commit is contained in:
parent
5c8b768dc1
commit
2df3afc00e
@ -40,7 +40,7 @@ namespace HospitalDatabaseImplement.Models
|
||||
}
|
||||
return new Disease()
|
||||
{
|
||||
Id = model.Id,
|
||||
//Id = model.Id,
|
||||
Name = model.Name,
|
||||
Description = model.Description,
|
||||
DoctorId = model.DoctorId
|
||||
|
@ -72,7 +72,7 @@ namespace HospitalDatabaseImplement.Models
|
||||
{
|
||||
return new Patient()
|
||||
{
|
||||
Id = model.Id,
|
||||
// Id = model.Id,
|
||||
FIO = model.FIO,
|
||||
Address = model.Address,
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace HospitalDatabaseImplement.Modelss
|
||||
{
|
||||
return new Recipe()
|
||||
{
|
||||
Id = model.Id,
|
||||
//Id = model.Id,
|
||||
IssueDate = model.IssueDate,
|
||||
Description = model.Description,
|
||||
DiseaseId = model.DiseaseId,
|
||||
|
@ -1,5 +1,7 @@
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDataModels.Models;
|
||||
using HospitalDoctorApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
@ -13,34 +15,15 @@ namespace HospitalDoctorApp.Controllers
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreatePatient()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CreateDisease()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CreateRecipe()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIClient.GetRequest<List<PatientViewModel>>($"api/visit/getpatients?doctorId={APIClient.Doctor.Id}"));
|
||||
return View(APIClient.GetRequest<List<PatientViewModel>>($"api/patient/getpatients?doctorId={APIClient.Doctor.Id}"));
|
||||
|
||||
}
|
||||
public IActionResult IndexRecipes()
|
||||
@ -50,7 +33,7 @@ View(APIClient.GetRequest<List<PatientViewModel>>($"api/visit/getpatients?doctor
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIClient.GetRequest<List<RecipeViewModel>>($"api/animal/getrecipelist?doctorId={APIClient.Doctor.Id}"));
|
||||
View(APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorId={APIClient.Doctor.Id}"));
|
||||
|
||||
}
|
||||
public IActionResult IndexDiseases()
|
||||
@ -161,5 +144,392 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Создание
|
||||
public IActionResult CreatePatient()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
public IActionResult CreateRecipe()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
public IActionResult CreateDisease()
|
||||
{
|
||||
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>("api/recipe/getrecipelist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreatePatient(string name, string address, DateTime patientdate)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(address))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIClient.PostRequest("api/patient/createpatient", new PatientBindingModel
|
||||
{
|
||||
FIO = name,
|
||||
BirthDate = patientdate,
|
||||
Address = address,
|
||||
DoctorId = APIClient.Doctor.Id
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateRecipe(string description, DateTime issueDate)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIClient.PostRequest("api/recipe/createrecipe", new RecipeBindingModel
|
||||
{
|
||||
Description = description,
|
||||
IssueDate = issueDate,
|
||||
DoctorId = APIClient.Doctor.Id
|
||||
});
|
||||
Response.Redirect("IndexRecipes");
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateDisease(int doctorId, string name, string description)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
if (string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIClient.PostRequest("api/disease/createdisease", new DiseaseBindingModel
|
||||
{
|
||||
Name = name,
|
||||
DoctorId = doctorId,
|
||||
|
||||
Description = description
|
||||
});
|
||||
Response.Redirect("IndexDiseases");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Удаление
|
||||
public IActionResult DeletePatient()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>("api/patient/getpatients");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeletePatient(int patient)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIClient.PostRequest("api/patient/deletepatient", new PatientBindingModel
|
||||
{
|
||||
Id = patient
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
public IActionResult DeleteRecipe()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
|
||||
return View();
|
||||
}
|
||||
public IActionResult DeleteDisease()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Diseases = APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?doctorid={APIClient.Doctor.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteRecipe(int recipe)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIClient.PostRequest("api/recipe/deleterecipe", new RecipeBindingModel
|
||||
{
|
||||
Id = recipe
|
||||
});
|
||||
Response.Redirect("IndexRecipes");
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteDisease(int disease)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIClient.PostRequest("api/disease/deletedisease", new DiseaseBindingModel
|
||||
{
|
||||
Id = disease
|
||||
});
|
||||
Response.Redirect("IndexDiseases");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Обновление
|
||||
public IActionResult UpdatePatient()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>("api/patient/getpatients");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdatePatient(int patient, string name, string address, DateTime birthdate)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIClient.PostRequest("api/patient/updatepatient", new PatientBindingModel
|
||||
{
|
||||
Id = patient,
|
||||
FIO = name,
|
||||
Address = address,
|
||||
BirthDate = birthdate,
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
public IActionResult UpdateRecipe()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateRecipe(int recipe, string description, DateTime issuedate)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIClient.PostRequest("api/recipe/updaterecipe", new RecipeBindingModel
|
||||
{
|
||||
Id = recipe,
|
||||
Description = description,
|
||||
IssueDate = issuedate
|
||||
|
||||
});
|
||||
Response.Redirect("IndexRecipes");
|
||||
}
|
||||
|
||||
public IActionResult UpdateDisease()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Diseases = APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?doctorid={APIClient.Doctor.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateDisease(int disease, string description, string name)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIClient.PostRequest("api/disease/updatedisease", new DiseaseBindingModel
|
||||
{
|
||||
|
||||
Id = disease,
|
||||
Name = name,
|
||||
Description = description,
|
||||
|
||||
|
||||
|
||||
});
|
||||
Response.Redirect("IndexDisease");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Промежуточные таблицы
|
||||
public IActionResult PatientRecipes()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
|
||||
ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>($"api/patient/getpatients");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void PatientRecipes(int recipe, string description, DateTime date,
|
||||
List<int> patients)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
Dictionary<int, IPatientModel> v = new Dictionary<int, IPatientModel>();
|
||||
foreach (int patient in patients)
|
||||
{
|
||||
v.Add(patient, new PatientSearchModel { Id = patient } as IPatientModel);
|
||||
}
|
||||
APIClient.PostRequest("api/recipe/updaterecipe?isconnection=true", new RecipeBindingModel
|
||||
{
|
||||
Id = recipe,
|
||||
Description = description,
|
||||
IssueDate = date,
|
||||
DoctorId = APIClient.Doctor.Id,
|
||||
RecipePatients = v
|
||||
});
|
||||
Response.Redirect("IndexRecipes");
|
||||
}
|
||||
public IActionResult ProcedurePatients()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>($"api/patient/getpatients?doctorid={APIClient.Doctor.Id}");
|
||||
ViewBag.Procedures = APIClient.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void ProcedurePatients(int patient, string name, DateTime date,
|
||||
List<int> procedures)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || date == new DateTime())
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
Dictionary<int, IProcedureModel> s = new Dictionary<int, IProcedureModel>();
|
||||
foreach (int procedure in procedures)
|
||||
{
|
||||
s.Add(procedure, new ProcedureSearchModel { Id = procedure } as IProcedureModel);
|
||||
}
|
||||
APIClient.PostRequest("api/patient/updatepatient?isconnection=true", new PatientBindingModel
|
||||
{
|
||||
Id = patient,
|
||||
FIO = name,
|
||||
BirthDate = date,
|
||||
DoctorId = APIClient.Doctor.Id,
|
||||
PatientProcedures = s
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<PatientViewModel, List<string>>? GetPatient(int patientId)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIClient.GetRequest<Tuple<PatientViewModel, List<string>>>($"api/patient/getpatient?patientid={patientId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public Tuple<RecipeViewModel, List<string>>? GetRecipe(int recipeId)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIClient.GetRequest<Tuple<RecipeViewModel, List<string>>>($"api/recipe/getrecipe?recipeid={recipeId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public Tuple<ProcedureViewModel, List<string>>? GetProcedure(int procedureId)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIClient.GetRequest<Tuple<ProcedureViewModel, List<string>>>($"api/procedure/getprocedure?procedureid={procedureId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,12 @@
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="Update">Редактировать пациента</a>
|
||||
<a asp-action="Delete">Удалить пациента</a>
|
||||
<a asp-action="UpdatePatient">Редактировать пациента</a>
|
||||
<a asp-action="DeletePatient">Удалить пациента</a>
|
||||
<a asp-action="ServiceVisits">Связать пацииента и процедуру</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="Create">Создать пациента</a>
|
||||
<a asp-action="CreatePatient">Создать пациента</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
86
Hospital/HospitalRestApi/Controllers/DiseaseController.cs
Normal file
86
Hospital/HospitalRestApi/Controllers/DiseaseController.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDatabaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class DiseaseController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDiseaseLogic _disease;
|
||||
|
||||
public DiseaseController(ILogger<DiseaseController> logger,
|
||||
IDiseaseLogic disease)
|
||||
{
|
||||
_logger = logger;
|
||||
_disease = disease;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<DiseaseViewModel>? GetDiseases(int? doctorId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!doctorId.HasValue)
|
||||
return _disease.ReadList(null);
|
||||
return _disease.ReadList(new DiseaseSearchModel
|
||||
{
|
||||
DoctorId = doctorId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка по доктору id ={ Id}", doctorId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateDisease(DiseaseBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_disease.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания прививки");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateDisease(DiseaseBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _disease.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить привику");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteDisease(DiseaseBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _disease.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления привики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
105
Hospital/HospitalRestApi/Controllers/PatientController.cs
Normal file
105
Hospital/HospitalRestApi/Controllers/PatientController.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDatabaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class PatientController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPatientLogic _patient;
|
||||
public PatientController(ILogger<PatientController> logger, IPatientLogic patient)
|
||||
{
|
||||
_logger = logger;
|
||||
_patient = patient;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<PatientViewModel, List<string>>? GetPatient(int PatientId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _patient.ReadElement(new PatientSearchModel { Id = PatientId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
var res = Tuple.Create(elem, elem.PatientProcedures.Select(x => x.Value.Name).ToList());
|
||||
res.Item1.PatientProcedures = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения визита по id={Id}", PatientId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<PatientViewModel> GetPatients(int? doctorId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<PatientViewModel> res;
|
||||
if (!doctorId.HasValue)
|
||||
res = _patient.ReadList(null);
|
||||
else
|
||||
res = _patient.ReadList(new PatientSearchModel { DoctorId = doctorId });
|
||||
foreach (var patient in res)
|
||||
patient.PatientProcedures = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка визитов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool CreatePatient(PatientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _patient.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось создать визит");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdatePatient(bool isConnection, PatientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!isConnection)
|
||||
model.PatientProcedures = null!;
|
||||
return _patient.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить визит");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeletePatient(PatientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _patient.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления визита");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
108
Hospital/HospitalRestApi/Controllers/RecipeController.cs
Normal file
108
Hospital/HospitalRestApi/Controllers/RecipeController.cs
Normal file
@ -0,0 +1,108 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDatabaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class RecipeController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRecipeLogic _recipe;
|
||||
public RecipeController(ILogger<RecipeController> logger, IRecipeLogic recipe)
|
||||
{
|
||||
_logger = logger;
|
||||
_recipe = recipe;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<RecipeViewModel, List<string>>? GetRecipe(int recipeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _recipe.ReadElement(new RecipeSearchModel { Id = recipeId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
var res = Tuple.Create(elem, elem.RecipePatients.Select(x => x.Value.FIO).ToList());
|
||||
res.Item1.RecipePatients = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения рецепта по id={Id}", recipeId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<RecipeViewModel>? GetRecipeList(int? doctorId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<RecipeViewModel> res;
|
||||
if (!doctorId.HasValue)
|
||||
res = _recipe.ReadList(null);
|
||||
else
|
||||
res = _recipe.ReadList(new RecipeSearchModel { DoctorId = doctorId });
|
||||
foreach (var recipe in res)
|
||||
recipe.RecipePatients = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка рецептов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool CreateRecipe(RecipeBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _recipe.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось создать рецепт");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateRecipe(bool isConnection, RecipeBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!isConnection)
|
||||
model.RecipePatients = null!;
|
||||
return _recipe.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить рецепт");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteRecipe(RecipeBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _recipe.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления рецепта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -7,11 +7,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Views\Home\Registr.cshtml" />
|
||||
<Content Remove="Views\Home\Register.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Views\Home\Registr.cshtml" />
|
||||
<Compile Include="Views\Home\Register.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -20,7 +20,6 @@
|
||||
<ProjectReference Include="..\HospitalDatabaseImplement\HospitalDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\HospitalDataModels\HospitalDataModels.csproj" />
|
||||
<ProjectReference Include="..\HospitalRestApi\HospitalRestApi.csproj" />
|
||||
<ProjectReference Include="..\Hospital\HospitalView.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
1
Hospital/PharmacistApp/Views/Home/Register.cshtml
Normal file
1
Hospital/PharmacistApp/Views/Home/Register.cshtml
Normal file
@ -0,0 +1 @@
|
||||
|
@ -1,48 +0,0 @@
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
|
||||
< div class= "text-center" >
|
||||
|
||||
< h2 class= "display-4" > Регистрация </ h2 >
|
||||
</ div >
|
||||
< form method = "post" >
|
||||
|
||||
< div class= "row" >
|
||||
|
||||
< div class= "col-4" > Email:</ div >
|
||||
|
||||
< div class= "col-8" >< input type = "text" name = "email" /></ div >
|
||||
|
||||
</ div >
|
||||
|
||||
< div class= "row" >
|
||||
|
||||
< div class= "col-4" > Пароль:</ div >
|
||||
|
||||
< div class= "col-8" >< input type = "password" name = "password" /></ div >
|
||||
|
||||
</ div >
|
||||
|
||||
< div class= "row" >
|
||||
|
||||
< div class= "col-4" > ФИО:</ div >
|
||||
|
||||
< div class= "col-8" >< input type = "text" name = "fio" /></ div >
|
||||
|
||||
</ div >
|
||||
|
||||
< div class= "row" >
|
||||
|
||||
< div class= "col-8" ></ div >
|
||||
|
||||
< div class= "col-4" >
|
||||
|
||||
< input type = "submit" value = "Регистрация"
|
||||
|
||||
class= "btn btn-primary" />
|
||||
|
||||
</ div >
|
||||
|
||||
</ div >
|
||||
</ form >
|
@ -6,5 +6,5 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"IPAddress": "http://localhost:5025/"
|
||||
"IPAddress": "http://localhost:5029/"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user