diff --git a/VeterinaryClinic/VeterinaryClinicBusinessLogics/MailWorker/AbstractMailWorker.cs b/VeterinaryClinic/VeterinaryClinicBusinessLogics/MailWorker/AbstractMailWorker.cs index fae95a3..3d73300 100644 --- a/VeterinaryClinic/VeterinaryClinicBusinessLogics/MailWorker/AbstractMailWorker.cs +++ b/VeterinaryClinic/VeterinaryClinicBusinessLogics/MailWorker/AbstractMailWorker.cs @@ -85,7 +85,20 @@ namespace VeterinaryClinicBusinessLogics.MailWorker { return; } + if (string.IsNullOrEmpty(info.MailAddress)) + { + _logger.LogWarning("MailAddress is null or empty"); + } + if (string.IsNullOrEmpty(info.Subject)) + { + _logger.LogWarning("Subject is null or empty"); + } + + if (string.IsNullOrEmpty(info.Path)) + { + _logger.LogWarning("Path is null or empty"); + } if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Path)) { return; diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Controllers/HomeController.cs b/VeterinaryClinic/VeterinaryClinicWebApp/Controllers/HomeController.cs index bf6b3cc..c4b8c5a 100644 --- a/VeterinaryClinic/VeterinaryClinicWebApp/Controllers/HomeController.cs +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Controllers/HomeController.cs @@ -276,7 +276,7 @@ public class HomeController : Controller _reportLogic.SaveVisitsInfoToPdfFile(new ReportBindingModel { - FileName = $@"D:\ {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.pdf", + FileName = $@"D:\report.pdf", UserId = APIClient.User.Id, DateFrom = dateFrom, DateTo = dateTo @@ -289,23 +289,19 @@ public class HomeController : Controller /// Îòïðàâèòü ïî ïî÷òå îò÷¸ò /// [HttpPost] - public void SendReport(DateTime dateFrom, DateTime dateTo) + public void SendReport() { if (APIClient.User == null) { throw new Exception("Íåîáõîäèìî àâòîðèçîâàòüñÿ!"); } - if (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue) - { - throw new Exception("Ââåäåíû íå âñå äàííûå!"); - } - _mailLogic.MailSendAsync(new MailSendInfoBindingModel { MailAddress = APIClient.User.Email, Subject = $"Îò÷åò {APIClient.User.FullName}", - Text = $"Îò÷åò ñ {dateFrom.ToShortDateString()} ïî {dateTo.ToShortDateString()}" + Text = "Âàø îò÷åò", + Path = "D:\\report.pdf" }); Response.Redirect("/Home/Reports"); diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Program.cs b/VeterinaryClinic/VeterinaryClinicWebApp/Program.cs index a29c6ec..15de035 100644 --- a/VeterinaryClinic/VeterinaryClinicWebApp/Program.cs +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Program.cs @@ -60,8 +60,6 @@ mailSender?.MailConfig(new MailConfigBindingModel PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString()) }); -APIClient.Connect(builder.Configuration); - // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Reports.cshtml b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Reports.cshtml index 7ae5e72..5960612 100644 --- a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Reports.cshtml +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Reports.cshtml @@ -41,16 +41,9 @@ - @*
- - +
-
*@ -
- - - -
+