Compare commits
10 Commits
3a7f1d205d
...
427b6f07b2
Author | SHA1 | Date | |
---|---|---|---|
427b6f07b2 | |||
c6518591c9 | |||
|
0c51e7a002 | ||
|
67b8f12ede | ||
|
bb68e9abcc | ||
|
324781aa40 | ||
|
dfe1c50ddc | ||
|
ae96bb65a2 | ||
|
e0e98a237c | ||
|
8f6ffe347f |
@ -2,10 +2,13 @@
|
||||
using NPOI.SS.UserModel;
|
||||
using PharmacistApp.Models;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
using VetClinicContracts.SearchModels;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataBaseImplement.Implements;
|
||||
using VetClinicDataBaseImplement.Models;
|
||||
using VetClinicDataModels.Models;
|
||||
|
||||
@ -27,8 +30,7 @@ namespace PharmacistApp.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={
|
||||
APIPharmacist.Pharmacist.Id}"));
|
||||
View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}"));
|
||||
|
||||
}
|
||||
|
||||
@ -143,7 +145,7 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
{
|
||||
_price = Convert.ToDouble(price);
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
@ -157,7 +159,7 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
MedicineName = name,
|
||||
Price = Math.Round(_price, 2),
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id
|
||||
}) ;
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
@ -253,7 +255,7 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
StringBuilder st = new StringBuilder(price);
|
||||
for(int i = 0; i < price.Length; i++)
|
||||
for (int i = 0; i < price.Length; i++)
|
||||
{
|
||||
if (price[i] == '.')
|
||||
st[i] = ',';
|
||||
@ -592,11 +594,150 @@ View(res);
|
||||
ViewBag.Services = APIPharmacist.GetRequest<List<ServiceViewModel>>($"api/service/getservices?pharmacistid={APIPharmacist.Pharmacist.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void AnimalListReport(List<int> services, string type)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (services.Count <= 0)
|
||||
{
|
||||
throw new Exception("Количество должно быть больше 0");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(type))
|
||||
{
|
||||
throw new Exception("Неверный тип отчета");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (type == "docx")
|
||||
{
|
||||
APIPharmacist.PostRequest("api/report/createanimallistwordfile", new ListAnimalsBindingModel
|
||||
{
|
||||
Services = services,
|
||||
FileName = "C:\\ReportsCourseWork\\wordfile.docx"
|
||||
});
|
||||
Response.Redirect("GetWordFile");
|
||||
}
|
||||
else
|
||||
{
|
||||
APIPharmacist.PostRequest("api/report/createanimallistexcelfile", new ListAnimalsBindingModel
|
||||
{
|
||||
Services = services,
|
||||
FileName = "C:\\ReportsCourseWork\\excelfile.xlsx"
|
||||
});
|
||||
Response.Redirect("GetExcelFile");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetWordFile()
|
||||
{
|
||||
return new PhysicalFileResult("C:\\ReportsCourseWork\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
}
|
||||
|
||||
public IActionResult GetExcelFile()
|
||||
{
|
||||
return new PhysicalFileResult("C:\\ReportsCourseWork\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Report()
|
||||
{
|
||||
ViewBag.Report = new List<VisitsGuidesBindingModel>();
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string GetAnimalsReport(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
List<VisitsGuidesViewModel> result;
|
||||
try
|
||||
{
|
||||
string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture);
|
||||
string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture);
|
||||
result = APIPharmacist.GetRequest<List<VisitsGuidesViewModel>>
|
||||
($"api/report/getvisitsguidesreport?datefrom={dateFromS}&dateto={dateToS}&pharmacistid={APIPharmacist.Pharmacist.Id}")!;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
string table = "";
|
||||
table += "<h2 class=\"text-custom-color-1\">Предварительный отчет</h2>";
|
||||
table += "<div class=\"table-responsive\">";
|
||||
table += "<table class=\"table table-striped table-bordered table-hover\">";
|
||||
table += "<thead class=\"table-dark\">";
|
||||
table += "<tr>";
|
||||
table += "<th scope=\"col\">Дата</th>";
|
||||
table += "<th scope=\"col\">Название медикамента</th>";
|
||||
table += "<th scope=\"col\">Услуга рекомендации</th>";
|
||||
table += "<th scope=\"col\">Название визита</th>";
|
||||
table += "</tr>";
|
||||
table += "</thead>";
|
||||
foreach (var medicine in result)
|
||||
{
|
||||
table += "<tbody>";
|
||||
table += "<tr>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{medicine.MedicineName}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += "</tr>";
|
||||
foreach(var guidance in medicine.Guidances)
|
||||
{
|
||||
table += "<tr>";
|
||||
table += $"<td>{guidance.Date}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{guidance.ServiceName}</td>";
|
||||
table += $"<td></td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
foreach (var visit in medicine.Visits)
|
||||
{
|
||||
table += "<tr>";
|
||||
table += $"<td>{visit.DateVisit}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{visit.NameVisit}</td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
table += "</tbody>";
|
||||
}
|
||||
table += "</table>";
|
||||
table += "</div>";
|
||||
return table;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Report(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/report/sendvisitsguidesreporttoemail", new VisitsGuidesBindingModel
|
||||
{
|
||||
FileName = "C:\\ReportsCourseWork\\pdffile.pdf",
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo,
|
||||
Email = APIPharmacist.Pharmacist.Email
|
||||
|
||||
});
|
||||
Response.Redirect("Report");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,9 +19,18 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-2"><input type="submit" value="Word" class="btn btn-primary" /></div>
|
||||
<div class="col-2"><input type="submit" value="Excel" class="btn btn-primary" /></div>
|
||||
<div class="file-format">
|
||||
<label class="form-label">Выберите формат файла:</label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="type" value="docx" id="docx">
|
||||
<label class="form-check-label" for="docx">Word-файл</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="type" value="xlsx" id="xlsx" checked>
|
||||
<label class="form-check-label" for="xlsx">Excel-файл</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="submit" class="btn btn-block btn-outline-dark w-100">Создать</button>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -1,60 +1,67 @@
|
||||
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Report";
|
||||
ViewData["Title"] = "Report";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Список медикаментов с расшифровкой по визитам и рекомендациям</h1>
|
||||
|
||||
<div class="container">
|
||||
<div class="text-center mb-4">
|
||||
<h2 class="text-custom-color-1">Отчет по медикаментам за период</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateFrom" class="form-label text-custom-color-1">Начало периода:</label>
|
||||
<input type="datetime-local" id="dateFrom" name="dateFrom" class="form-control" placeholder="Выберите дату начала периода">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateTo" class="form-label text-custom-color-1">Окончание периода:</label>
|
||||
<input type="datetime-local" id="dateTo" name="dateTo" class="form-control" placeholder="Выберите дату окончания периода">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-8"></div>
|
||||
<div class="col-md-4">
|
||||
<button type="submit" class="btn btn-outline-dark w-100 text-center d-flex justify-content-md-center">Отправить на почту</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-8"></div>
|
||||
<div class="col-md-4">
|
||||
<button type="button" id="demonstrate" class="btn btn-outline-dark w-100 text-center d-flex justify-content-md-center">Продемонстрировать</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="report"></div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
// if (Model == null)
|
||||
// {
|
||||
// <h3 class="display-4">Будь добр, дружок, зайди!</h3>
|
||||
// return;
|
||||
// }
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Начальная дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="startDate" name="startDate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Конечная дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="endDate" name="endDate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Дата
|
||||
</th>
|
||||
<th>
|
||||
Медикамент
|
||||
</th>
|
||||
<th>
|
||||
Визит
|
||||
</th>
|
||||
<th>
|
||||
Рекомендация
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
будет заполняться вьюшками отчета
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать отчет" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Отправить на почту" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function check() {
|
||||
var dateFrom = $('#dateFrom').val();
|
||||
var dateTo = $('#dateTo').val();
|
||||
if (dateFrom && dateTo) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetAnimalsReport",
|
||||
data: { dateFrom: dateFrom, dateTo: dateTo },
|
||||
success: function (result) {
|
||||
if (result != null) {
|
||||
$('#report').html(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#demonstrate').on('click', (e) => check());
|
||||
</script>
|
||||
}
|
@ -11,12 +11,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicRestApi", "VetClin
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicContracts", "VetClinicContracts\VetClinicContracts.csproj", "{F2944E52-DC59-42B0-98D2-AC93E22DAB8C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicAdminApp", "VetClinicAdminApi\VetClinicAdminApp.csproj", "{75280728-CC4C-4C43-8921-2DC4AD8A9192}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicDataBaseImplement", "VetClinicDataBaseImplement\VetClinicDataBaseImplement.csproj", "{55D8A594-2412-49E5-B306-F7D0385A870D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PharmacistApp", "PharmacistApp\PharmacistApp.csproj", "{EF0A9AB0-6C45-4FC7-9A6E-91C064477CD5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicAdminApp", "VetClinicAdminApp\VetClinicAdminApp.csproj", "{762FE6A3-9A10-4542-B8D4-EC84456AF93A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -39,10 +39,6 @@ Global
|
||||
{F2944E52-DC59-42B0-98D2-AC93E22DAB8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F2944E52-DC59-42B0-98D2-AC93E22DAB8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F2944E52-DC59-42B0-98D2-AC93E22DAB8C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{75280728-CC4C-4C43-8921-2DC4AD8A9192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{75280728-CC4C-4C43-8921-2DC4AD8A9192}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{75280728-CC4C-4C43-8921-2DC4AD8A9192}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{75280728-CC4C-4C43-8921-2DC4AD8A9192}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{55D8A594-2412-49E5-B306-F7D0385A870D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{55D8A594-2412-49E5-B306-F7D0385A870D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{55D8A594-2412-49E5-B306-F7D0385A870D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -51,6 +47,10 @@ Global
|
||||
{EF0A9AB0-6C45-4FC7-9A6E-91C064477CD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EF0A9AB0-6C45-4FC7-9A6E-91C064477CD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EF0A9AB0-6C45-4FC7-9A6E-91C064477CD5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{762FE6A3-9A10-4542-B8D4-EC84456AF93A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{762FE6A3-9A10-4542-B8D4-EC84456AF93A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{762FE6A3-9A10-4542-B8D4-EC84456AF93A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{762FE6A3-9A10-4542-B8D4-EC84456AF93A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -157,7 +157,6 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"api/service/getservices?adminid={APIAdmin.Admin.Id}");
|
||||
return View();
|
||||
}
|
||||
public IActionResult CreateVaccination()
|
||||
@ -167,7 +166,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(string name, DateTime visitdate)
|
||||
public void Create(string name, DateTime date)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
@ -180,7 +179,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
APIAdmin.PostRequest("api/visit/createvisit", new VisitBindingModel
|
||||
{
|
||||
NameVisit = name,
|
||||
DateVisit = visitdate,
|
||||
DateVisit = date,
|
||||
AdminId = APIAdmin.Admin.Id
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
@ -205,7 +204,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
Response.Redirect("IndexAnimals");
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateVaccination(int animale, string name, string cost,DateTime date)
|
||||
public void CreateVaccination(int animal, string name, string cost,DateTime date)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
@ -241,8 +240,8 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
}
|
||||
APIAdmin.PostRequest("api/vaccination/createvaccination", new VaccinationBindingModel
|
||||
{
|
||||
AnimalId = animal,
|
||||
NameVaccination = name,
|
||||
AnimalId = animale,
|
||||
CostVaccination = Math.Round(_cost, 2),
|
||||
DateStamp = date
|
||||
});
|
||||
@ -325,13 +324,13 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?pharmacistid={APIAdmin.Admin.Id}");
|
||||
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?adminid={APIAdmin.Admin.Id}");
|
||||
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"api/service/getservices");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Update(int visit, string name, DateTime vistdate)
|
||||
public void Update(int visit, string name, DateTime date)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
@ -345,7 +344,8 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
Id = visit,
|
||||
NameVisit = name,
|
||||
DateVisit = vistdate,
|
||||
AdminId = APIAdmin.Admin.Id,
|
||||
DateVisit = date,
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
@ -457,6 +457,17 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
public IActionResult Vaccinations()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
var res = APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?pharmacistid={APIAdmin.Admin.Id}");
|
||||
return
|
||||
View(res);
|
||||
|
||||
}
|
||||
public IActionResult UpdateVaccination()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
@ -469,27 +480,42 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateVaccination(int animale,int vaccination, string name, double cost, DateTime date)
|
||||
public void UpdateVaccination(int vaccination,int animal, string name, string cost, DateTime date)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
StringBuilder st = new StringBuilder(cost);
|
||||
for (int i = 0; i < cost.Length; i++)
|
||||
{
|
||||
if (cost[i] == '.')
|
||||
st[i] = ',';
|
||||
}
|
||||
cost = st.ToString();
|
||||
double _cost;
|
||||
try
|
||||
{
|
||||
_cost = Convert.ToDouble(cost);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || _cost <= 0)
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIAdmin.PostRequest("api/vaccination/updatevaccination", new VaccinationBindingModel
|
||||
{
|
||||
|
||||
Id = vaccination,
|
||||
AnimalId = animale,
|
||||
AnimalId = animal,
|
||||
NameVaccination = name,
|
||||
CostVaccination = cost,
|
||||
CostVaccination = Math.Round(_cost, 2),
|
||||
DateStamp = date
|
||||
|
||||
});
|
||||
Response.Redirect("IndexVaccination");
|
||||
Response.Redirect("IndexVaccinations");
|
||||
}
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
@ -540,6 +566,21 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public VaccinationViewModel GetVaccination(int adminId)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
var result = APIAdmin.GetRequest<VaccinationViewModel>($"api/vaccination/getvaccination?adminid={adminId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="date" name="date" />
|
||||
<input type="datetime-local" id="date" name="date" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -36,6 +36,5 @@
|
||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
</form>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="date" name="date"/>
|
||||
<input type="datetime-local" id="date" name="date" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -36,23 +36,6 @@
|
||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
</form>
|
||||
<script>
|
||||
$('#animal').on('change', function () {
|
||||
check();
|
||||
});
|
||||
function check() {
|
||||
if (snack) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/GetAnimal",
|
||||
data: { animal: animal },
|
||||
success: function (result) {
|
||||
$("#animal").val(result);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
@ -33,6 +33,9 @@
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Стоимость
|
||||
</th>
|
||||
<th>
|
||||
Дата
|
||||
</th>
|
||||
|
@ -22,16 +22,16 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="date" name="date" />
|
||||
<input type="datetime-local" id="date" name="date" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Услуги:</div>
|
||||
<div class="col-8">
|
||||
<select name="services" class="form-control" multiple size="5" id="services">
|
||||
@foreach (var services in ViewBag.Services)
|
||||
@foreach (var service in ViewBag.Services)
|
||||
{
|
||||
<option value="@services.Id" data-name="@services.ServiceName">@services.ServiceName</option>
|
||||
<option value="@service.Id" data-name="@service.ServiceName">@service.ServiceName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
@ -48,14 +48,16 @@
|
||||
<script>
|
||||
function check() {
|
||||
var visit = $('#visit').val();
|
||||
$("#services option:selected").removeAttr("selected");
|
||||
if (visit) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetVisit",
|
||||
data: { visitId: visit },
|
||||
success: function (result) {
|
||||
$('#name').val(result.item1.vistName);
|
||||
$('#date').val(result.item1.date);
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.item1.nameVisit);
|
||||
$('#date').val(result.item1.dateVisit);
|
||||
$.map(result.item2, function (n) {
|
||||
console.log("#" + n);
|
||||
$(`option[data-name=${n}]`).attr("selected", "selected")
|
||||
|
@ -38,7 +38,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="date" name="date"/>
|
||||
<input type="datetime-local" id="date" name="date" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -48,21 +48,23 @@
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
</form>
|
||||
<script>
|
||||
$('#animal').on('change', function () {
|
||||
check();
|
||||
});
|
||||
function check() {
|
||||
if (snack) {
|
||||
|
||||
var vaccination = $('#vaccination').val();
|
||||
$("#animal option:selected").removeAttr("selected");
|
||||
if (vaccination) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
method: "GET",
|
||||
url: "/Home/GetVaccination",
|
||||
data: { vaccinationId: vaccinationId },
|
||||
data: { vaccinationId: vaccination },
|
||||
success: function (result) {
|
||||
$('#name').val(result.text);
|
||||
$('#cost').val(result.text);
|
||||
$('#date').val(result.date);
|
||||
$(`option[data-name=${result.animalId}]`).attr("selected", "selected")
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.nameVaccination);
|
||||
$('#cost').val(result.costVaccination);
|
||||
$('#date').val(result.dateStamp);
|
||||
$(`option[data-name=${result.vaccinationId}]`).attr("selected", "selected")
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -50,7 +50,7 @@
|
||||
$('#family').val(result.item1.family);
|
||||
$.map(result.item2, function (n) {
|
||||
console.log("#" + n);
|
||||
$("#" + n).attr("selected", "selected")
|
||||
$(`option[data-name=${n}]`).attr("selected", "selected")
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ using VetClinicContracts.BusinessLogicsContracts;
|
||||
using VetClinicContracts.SearchModels;
|
||||
using VetClinicContracts.StoragesContracts;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataBaseImplement.Implements;
|
||||
|
||||
namespace VetClinicBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -19,13 +20,16 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
private readonly IMedicineStorage _medicineStorage;
|
||||
private readonly AbstractSaveToExcelPharmacist _saveToExcel;
|
||||
private readonly AbstractSaveToWordPharmacist _saveToWord;
|
||||
private readonly AbstractSaveToPdfPharmacist _saveToPdf;
|
||||
public ReportLogicPharmacist(IServiceStorage serviceStorage, IMedicineStorage medicineStorage,
|
||||
AbstractSaveToExcelPharmacist saveToExcel, AbstractSaveToWordPharmacist saveToWord)
|
||||
AbstractSaveToExcelPharmacist saveToExcel, AbstractSaveToWordPharmacist saveToWord,
|
||||
AbstractSaveToPdfPharmacist saveToPdf)
|
||||
{
|
||||
_serviceStorage = serviceStorage;
|
||||
_medicineStorage = medicineStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
|
||||
public List<ListAnimalsViewModel> GetServiceAnimals(List<int> services)
|
||||
@ -85,5 +89,57 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
ServicesAnimals = GetServiceAnimals(model.Services)
|
||||
});
|
||||
}
|
||||
|
||||
public List<VisitsGuidesViewModel> GetMedicineVisitsAndGuidances(VisitsGuidesBindingModel model)
|
||||
{
|
||||
List<VisitsGuidesViewModel> ans = new();
|
||||
List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<GuidanceViewModel>>>>> responseGuides =
|
||||
_medicineStorage.GetGuidancesInfo(new VisitGuidesSearchModel { DateFrom = model.DateFrom!, DateTo = model.DateTo!, PharmacistId = model.PharmacistId!});
|
||||
List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<VisitViewModel>>>>> responseVisits =
|
||||
_medicineStorage.GetVisitsInfo(new VisitGuidesSearchModel { DateFrom = model.DateFrom!, DateTo = model.DateTo!, PharmacistId = model.PharmacistId! });
|
||||
Dictionary<int, VisitsGuidesViewModel> dict = new();
|
||||
|
||||
foreach(var medicine in responseGuides)
|
||||
{
|
||||
dict.Add(medicine.Item1.Id, new());
|
||||
dict[medicine.Item1.Id].MedicineName = medicine.Item1.MedicineName;
|
||||
foreach(var service in medicine.Item2)
|
||||
{
|
||||
foreach(var guidance in service.Item2)
|
||||
{
|
||||
dict[medicine.Item1.Id].Guidances.Add(guidance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var medicine in responseVisits)
|
||||
{
|
||||
HashSet<int> used = new();
|
||||
foreach (var service in medicine.Item2)
|
||||
{
|
||||
foreach (var visit in service.Item2)
|
||||
{
|
||||
if (used.Contains(visit.Id))
|
||||
continue;
|
||||
dict[medicine.Item1.Id].Visits.Add(visit);
|
||||
}
|
||||
}
|
||||
ans.Add(dict[medicine.Item1.Id]);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
public void SaveMedicinesToPdfFile(VisitsGuidesBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список медикаментов",
|
||||
DateFrom = model.DateFrom!,
|
||||
DateTo = model.DateTo!,
|
||||
Medicines = GetMedicineVisitsAndGuidances(model)
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,12 +111,11 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
var element = _vaccinationStorage.GetElement(new VaccinationSearchModel
|
||||
{
|
||||
NameVaccination = model.NameVaccination,
|
||||
DateStamp = model.DateStamp,
|
||||
AnimalId = model.AnimalId,
|
||||
AnimalId = model.AnimalId
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Прививка для этого услуги с таким текстом уже есть");
|
||||
throw new InvalidOperationException("Прививка для этого животного с таким текстом уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ true)
|
||||
throw new ArgumentNullException("Нет названия визита",
|
||||
nameof(model.NameVisit));
|
||||
}
|
||||
if (model.DateVisit != null)
|
||||
if (model.DateVisit == null)
|
||||
{
|
||||
throw new ArgumentNullException("Нет времени визита",
|
||||
nameof(model.DateVisit));
|
||||
|
@ -0,0 +1,64 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace VetClinicBusinessLogic.MailWorker
|
||||
{
|
||||
public abstract class AbstractMailWorker
|
||||
{
|
||||
protected string _mailLogin = string.Empty;
|
||||
protected string _mailPassword = string.Empty;
|
||||
protected string _smtpClientHost = string.Empty;
|
||||
protected int _smtpClientPort;
|
||||
protected string _popHost = string.Empty;
|
||||
protected int _popPort;
|
||||
private readonly IPharmacistLogic _pharmacistLogic;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public AbstractMailWorker(ILogger<AbstractMailWorker> logger, IPharmacistLogic pharmacistLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_pharmacistLogic = pharmacistLogic;
|
||||
}
|
||||
|
||||
public void MailConfig(MailConfigBindingModel config)
|
||||
{
|
||||
_mailLogin = config.MailLogin;
|
||||
_mailPassword = config.MailPassword;
|
||||
_smtpClientHost = config.SmtpClientHost;
|
||||
_smtpClientPort = config.SmtpClientPort;
|
||||
_popHost = config.PopHost;
|
||||
_popPort = config.PopPort;
|
||||
_logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPOrt}, {popHost}, {popPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
|
||||
}
|
||||
|
||||
public async void MailSendAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
|
||||
|
||||
await SendMailAsync(info);
|
||||
}
|
||||
|
||||
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
|
||||
}
|
||||
}
|
50
VetClinic/VetClinicBusinessLogic/MailWorker/MailWorker.cs
Normal file
50
VetClinic/VetClinicBusinessLogic/MailWorker/MailWorker.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Net.Mime;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace VetClinicBusinessLogic.MailWorker
|
||||
{
|
||||
public class MailKitWorker : AbstractMailWorker
|
||||
{
|
||||
public MailKitWorker(ILogger<MailKitWorker> logger, IPharmacistLogic pharmacistLogic) : base(logger, pharmacistLogic) { }
|
||||
|
||||
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
using var objMailMessage = new MailMessage();
|
||||
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
||||
|
||||
try
|
||||
{
|
||||
objMailMessage.From = new MailAddress(_mailLogin);
|
||||
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
||||
objMailMessage.Subject = info.Subject;
|
||||
objMailMessage.Body = info.Text;
|
||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||
Attachment attachment = new Attachment("C:\\ReportsCourseWork\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
|
||||
objMailMessage.Attachments.Add(attachment);
|
||||
|
||||
objSmtpClient.UseDefaultCredentials = false;
|
||||
objSmtpClient.EnableSsl = true;
|
||||
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
||||
|
||||
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.OfficePackage.HelperEnums;
|
||||
using VetClinicBusinessLogic.OfficePackage.HelperModels;
|
||||
using VetClinicDataBaseImplement.Implements;
|
||||
|
||||
namespace VetClinicBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdfPharmacist
|
||||
{
|
||||
public void CreateDoc(PdfInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = info.Title,
|
||||
Style =
|
||||
"NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style
|
||||
= "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateTable(new List<string> { "4cm", "4cm", "4cm", "4cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Дата", "Название медикамента", "Услуга рекомендации",
|
||||
"Название визита" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var medicine in info.Medicines)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "", medicine.MedicineName, "", "" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach(var visit in medicine.Visits)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { visit.DateVisit.ToString(), "", "", visit.NameVisit },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
}
|
||||
foreach (var guidance in medicine.Guidances)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { guidance.Date.ToString(), "", guidance.ServiceName, "" },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
}
|
||||
}
|
||||
SavePdf(info);
|
||||
}
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum PdfParagraphAlignmentType
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Rigth
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicDataBaseImplement.Implements;
|
||||
|
||||
namespace VetClinicBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public DateTime DateFrom { get; set; }
|
||||
public DateTime DateTo { get; set; }
|
||||
public List<VisitsGuidesViewModel> Medicines { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace VetClinicBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfParagraph
|
||||
{
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public string Style { get; set; } = string.Empty;
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace VetClinicBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfRowParameters
|
||||
{
|
||||
public List<string> Texts { get; set; } = new();
|
||||
public string Style { get; set; } = string.Empty;
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.OfficePackage.HelperEnums;
|
||||
using VetClinicBusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
|
||||
namespace VetClinicBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToPdfPharmacist : AbstractSaveToPdfPharmacist
|
||||
{
|
||||
private Document? _document;
|
||||
private Section? _section;
|
||||
private Table? _table;
|
||||
private static ParagraphAlignment
|
||||
GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание стилей для документа
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
private static void DefineStyles(Document document)
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
protected override void CreatePdf(PdfInfo info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||
{
|
||||
if (_section == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment =
|
||||
GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||
{
|
||||
if (_table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var row = _table.AddRow();
|
||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||
{
|
||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
Unit borderWidth = 0.5;
|
||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
row.Cells[i].Format.Alignment =
|
||||
GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
protected override void SavePdf(PdfInfo info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.NETCore.App" Version="2.1.30" />
|
||||
<PackageReference Include="NPOI" Version="2.7.0" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicContracts.BindingModels
|
||||
{
|
||||
public class MailConfigBindingModel
|
||||
{
|
||||
public string MailLogin { get; set; } = string.Empty;
|
||||
public string MailPassword { get; set; } = string.Empty;
|
||||
public string SmtpClientHost { get; set; } = string.Empty;
|
||||
public int SmtpClientPort { get; set; }
|
||||
public string PopHost { get; set; } = string.Empty;
|
||||
public int PopPort { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicContracts.BindingModels
|
||||
{
|
||||
public class MailSendInfoBindingModel
|
||||
{
|
||||
public string MailAddress { get; set; } = string.Empty;
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
public string Text { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -10,10 +10,10 @@ namespace VetClinicContracts.BindingModels
|
||||
public class VaccinationBindingModel : IVaccinationModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int AnimalId { get; set; }
|
||||
public string NameVaccination { get; set; } = string.Empty;
|
||||
public double CostVaccination { get; set; }
|
||||
public DateTime DateStamp { get; set; }
|
||||
public DateTime DateStamp { get; set; } = DateTime.Now;
|
||||
public int AnimalId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,9 @@ namespace VetClinicContracts.BindingModels
|
||||
public class VisitsGuidesBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public List<int> Medicines { get; set; } = new();
|
||||
DateTime DateFrom { get; set; } = DateTime.Now;
|
||||
DateTime DateTo { get; set; } = DateTime.Now;
|
||||
public DateTime DateFrom { get; set; } = DateTime.Now;
|
||||
public DateTime DateTo { get; set; } = DateTime.Now;
|
||||
public int? PharmacistId { get; set; }
|
||||
public string? Email { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,16 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataBaseImplement.Implements;
|
||||
|
||||
namespace VetClinicContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportLogicPharmacist //Будет дорабатываться
|
||||
public interface IReportLogicPharmacist
|
||||
{
|
||||
List<ListAnimalsViewModel> GetServiceAnimals(List<int> services);
|
||||
void SaveAnimalsToWordFile(ListAnimalsBindingModel model);
|
||||
void SaveAnimalsToExcelFile(ListAnimalsBindingModel model);
|
||||
List<VisitsGuidesViewModel> GetMedicineVisitsAndGuidances(VisitsGuidesBindingModel services);
|
||||
void SaveMedicinesToPdfFile(VisitsGuidesBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ namespace VetClinicContracts.SearchModels
|
||||
public List<int>? medicinesIds { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? PharmacistId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,5 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
public string MedicineName { get; set; } = string.Empty;
|
||||
public List<VisitViewModel> Visits { get; set; } = new();
|
||||
public List<GuidanceViewModel> Guidances { get; set; } = new();
|
||||
public DateTime DateFrom { get; set; } = DateTime.Now;
|
||||
public DateTime DateTo { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
@ -52,15 +52,15 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
public GuidanceViewModel? Update(GuidanceBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
var order = context.Guidances.Include(x => x.Service).FirstOrDefault(x => x.Id ==
|
||||
var element = context.Guidances.Include(x => x.Service).FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (order == null)
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(context, model);
|
||||
element.Update(context, model);
|
||||
context.SaveChanges();
|
||||
return order.GetViewModel;
|
||||
return element.GetViewModel;
|
||||
}
|
||||
public GuidanceViewModel? Delete(GuidanceBindingModel model)
|
||||
{
|
||||
|
@ -35,13 +35,8 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
}
|
||||
public List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<GuidanceViewModel>>>>> GetGuidancesInfo(VisitGuidesSearchModel model)
|
||||
{
|
||||
if (model.medicinesIds == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Medicines
|
||||
.Where(medicine => model.medicinesIds.Contains(medicine.Id))
|
||||
return context.Medicines.Where(medicine => medicine.PharmacistId == model.PharmacistId)
|
||||
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<GuidanceViewModel>>>>(medicine.GetViewModel,
|
||||
context.ServiceMedicines.Include(service => service.Service)
|
||||
.Include(service => service.Medicine).Where(service => medicine.Id == service.MedicineId).
|
||||
@ -52,14 +47,9 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
}
|
||||
public List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<VisitViewModel>>>>> GetVisitsInfo(VisitGuidesSearchModel model)
|
||||
{
|
||||
if (model.medicinesIds == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Medicines
|
||||
.Where(medicine => model.medicinesIds.Contains(medicine.Id))
|
||||
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<VisitViewModel>>>>(medicine.GetViewModel,
|
||||
return context.Medicines.Where(medicine => medicine.PharmacistId == model.PharmacistId)
|
||||
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<VisitViewModel>>>>(medicine.GetViewModel,
|
||||
context.ServiceMedicines.Include(service => service.Service)
|
||||
.Include(service => service.Medicine).Where(service => medicine.Id == service.MedicineId).
|
||||
Select(service => new Tuple<ServiceViewModel, List<VisitViewModel>>(service.Service.GetViewModel,
|
||||
|
@ -33,7 +33,7 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Vaccinations.Include(x => x.Animal).FirstOrDefault(x => (!model.Id.HasValue || model.Id == x.Id)
|
||||
&& (!model.AnimalId.HasValue || model.AnimalId == x.AnimalId) && (!model.DateFrom.HasValue || model.DateFrom <= x.DateStamp)
|
||||
&& (!model.AnimalId.HasValue || model.AnimalId == x.AnimalId) && (string.IsNullOrEmpty(model.NameVaccination) || model.NameVaccination == x.NameVaccination) && (!model.DateFrom.HasValue || model.DateFrom <= x.DateStamp)
|
||||
&& (!model.DateTo.HasValue || model.DateTo >= x.DateStamp))?.GetViewModel;
|
||||
}
|
||||
public VaccinationViewModel? Insert(VaccinationBindingModel model)
|
||||
@ -51,12 +51,11 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
public VaccinationViewModel? Update(VaccinationBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
var element = context.Vaccinations
|
||||
.Include(x => x.Animal)
|
||||
var element = context.Vaccinations.Include(x => x.Animal)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Vaccinations.Remove(element);
|
||||
element.Update(context, model);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
@ -65,7 +64,7 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
public VaccinationViewModel? Delete(VaccinationBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
var element = context.Vaccinations.FirstOrDefault(rec => rec.Id ==
|
||||
var element = context.Vaccinations.Include(x => x.Animal).FirstOrDefault(rec => rec.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
|
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicContracts.ViewModels;
|
||||
|
||||
namespace VetClinicDataBaseImplement.Implements
|
||||
{
|
||||
public class VisitsGuidesViewModel
|
||||
{
|
||||
string MedicineName { get; set; } = string.Empty;
|
||||
List<VisitViewModel> Visits { get; set; } = new();
|
||||
List<GuidanceViewModel> Guidances { get; set; } = new();
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using VetClinicDataBaseImplement;
|
||||
using VetClinicContracts.ViewModels;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using VetClinicDataBaseImplement;
|
||||
using VetClinicContracts.ViewModels;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace VetClinicDataBaseImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(VaccinationBindingModel? model)
|
||||
public void Update(VetClinicDatabase context, VaccinationBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -50,7 +50,8 @@ namespace VetClinicDataBaseImplement.Models
|
||||
NameVaccination = model.NameVaccination;
|
||||
CostVaccination = model.CostVaccination;
|
||||
DateStamp = model.DateStamp;
|
||||
|
||||
AnimalId = model.AnimalId;
|
||||
Animal = context.Animals.FirstOrDefault(x => x.Id == model.AnimalId);
|
||||
}
|
||||
|
||||
public VaccinationViewModel GetViewModel => new()
|
||||
|
@ -11,7 +11,7 @@ namespace VetClinicDataBaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS02;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS01;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ namespace VetClinicRestApi.Controllers
|
||||
[HttpGet]
|
||||
public List<AnimalViewModel>? GetAnimalList(int? adminId = null)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
List<AnimalViewModel> res;
|
||||
if (!adminId.HasValue)
|
||||
@ -50,12 +50,12 @@ namespace VetClinicRestApi.Controllers
|
||||
else
|
||||
res = _animal.ReadList(new AnimalSearchModel { AdminId = adminId });
|
||||
foreach (var animal in res)
|
||||
animal.VisitAnimals = null!;
|
||||
animal.VisitAnimals = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка животного");
|
||||
_logger.LogError(ex, "Ошибка получения списка животных");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
88
VetClinic/VetClinicRestApi/Controllers/ReportController.cs
Normal file
88
VetClinic/VetClinicRestApi/Controllers/ReportController.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using VetClinicBusinessLogic.BusinessLogics;
|
||||
using VetClinicBusinessLogic.MailWorker;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
using VetClinicDataBaseImplement.Implements;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ReportController : Controller
|
||||
{
|
||||
private readonly IReportLogicPharmacist _reportPharmacist;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
public ReportController(ILogger<ReportController> logger, IReportLogicPharmacist reportPharmacist,AbstractMailWorker mailWorker)
|
||||
{
|
||||
_reportPharmacist = reportPharmacist;
|
||||
_mailWorker = mailWorker;
|
||||
}
|
||||
[Microsoft.AspNetCore.Mvc.HttpGet]
|
||||
public IActionResult Index(ReportLogicPharmacist reportPharmacist)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateAnimalListWordFile(ListAnimalsBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportPharmacist.SaveAnimalsToWordFile(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateAnimalListExcelFile(ListAnimalsBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportPharmacist.SaveAnimalsToExcelFile(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<VisitsGuidesViewModel> GetVisitsGuidesReport(string dateFrom, string dateTo, int pharmacistId)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime DateFrom = DateTime.Parse(dateFrom);
|
||||
DateTime DateTo = DateTime.Parse(dateTo);
|
||||
VisitsGuidesBindingModel model = new();
|
||||
model.DateFrom = DateFrom;
|
||||
model.DateTo = DateTo;
|
||||
model.PharmacistId = pharmacistId;
|
||||
return _reportPharmacist.GetMedicineVisitsAndGuidances(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void SendVisitsGuidesReportToEmail(VisitsGuidesBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportPharmacist.SaveMedicinesToPdfFile(model);
|
||||
_mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = model.Email!,
|
||||
Subject = "Отчет по медикаментам",
|
||||
Text = "Лови"
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -77,8 +77,6 @@ namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!isConnection)
|
||||
model.ServiceVisits = null!;
|
||||
return _visit.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -4,6 +4,10 @@ using VetClinicContracts.StoragesContracts;
|
||||
using VetClinicDataBaseImplement.Implements;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using VetClinicBaseImplement.Implements;
|
||||
using VetClinicBusinessLogic.OfficePackage;
|
||||
using VetClinicBusinessLogic.OfficePackage.Implements;
|
||||
using VetClinicBusinessLogic.MailWorker;
|
||||
using VetClinicContracts.BindingModels;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -30,6 +34,12 @@ builder.Services.AddTransient<IPharmacistLogic, PharmacistLogic>();
|
||||
builder.Services.AddTransient<IServiceLogic, ServiceLogic>();
|
||||
builder.Services.AddTransient<IMedicineLogic, MedicineLogic>();
|
||||
builder.Services.AddTransient<IGuidanceLogic, GuidanceLogic>();
|
||||
builder.Services.AddTransient<IReportLogicPharmacist, ReportLogicPharmacist>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcelPharmacist, SaveToExcelPharmacist>();
|
||||
builder.Services.AddTransient<AbstractSaveToWordPharmacist, SaveToWordPharmacist>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfPharmacist, SaveToPdfPharmacist>();
|
||||
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
@ -40,6 +50,24 @@ builder.Services.AddSwaggerGen(c =>
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "VetClinicRestApi", Version = "v1" });
|
||||
});
|
||||
var app = builder.Build();
|
||||
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString()
|
||||
?? string.Empty,
|
||||
MailPassword =
|
||||
builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ??
|
||||
string.Empty,
|
||||
SmtpClientHost =
|
||||
builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ??
|
||||
string.Empty,
|
||||
SmtpClientPort =
|
||||
Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()),
|
||||
PopHost = builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ??
|
||||
string.Empty,
|
||||
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
|
||||
});
|
||||
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@ -6,6 +6,13 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Reports\**" />
|
||||
<Content Remove="Reports\**" />
|
||||
<EmbeddedResource Remove="Reports\**" />
|
||||
<None Remove="Reports\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
|
@ -5,5 +5,11 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"SmtpClientHost": "smtp.gmail.com",
|
||||
"SmtpClientPort": "587",
|
||||
"PopHost": "pop.gmail.com",
|
||||
"PopPort": "995",
|
||||
"MailLogin": "sasda3183@gmail.com",
|
||||
"MailPassword": "ozxp vjof uinv fcmj"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user