antoc0der 2024-05-27 03:49:16 +04:00
commit 71ab5700ce
8 changed files with 18 additions and 15 deletions

View File

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using System.Text.RegularExpressions;
using VeterinaryContracts.BindingModels;
using VeterinaryContracts.BusinessLogicContracts;
using VeterinaryContracts.SearchModels;
@ -95,6 +96,10 @@ namespace VeterinaryBusinessLogic.BusinessLogic
throw new ArgumentNullException("Нет Login клиента",
nameof(model.Login));
}
if (!Regex.IsMatch(model.Login, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"))
{
throw new ArgumentException("Некорретно введен email клиента", nameof(model.Login));
}
if (string.IsNullOrEmpty(model.Password))
{
throw new ArgumentNullException("Нет пароля клиента",

View File

@ -114,10 +114,6 @@ namespace VeterinaryBusinessLogic.BusinessLogic
PetName = model.PetName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Животное с таким названием уже есть");
}
}
}
}

View File

@ -16,9 +16,9 @@ namespace VeterinaryBusinessLogic.BusinessLogic
private readonly IPetStorage _petStorage;
private readonly AbstractSaveToExcelOwner _saveToExcel;
private readonly AbstractSaveToWordOwner _saveToWord;
private readonly AbstractSaveToPdfDoctor _saveToPdf;
private readonly AbstractSaveToPdfOwner _saveToPdf;
public ReportLogicOwner(IPetStorage petStorage,
AbstractSaveToExcelOwner saveToExcel, AbstractSaveToWordOwner saveToWord, AbstractSaveToPdfDoctor saveToPdf)
AbstractSaveToExcelOwner saveToExcel, AbstractSaveToWordOwner saveToWord, AbstractSaveToPdfOwner saveToPdf)
{
_petStorage = petStorage;
_saveToExcel = saveToExcel;

View File

@ -3,7 +3,7 @@
public class ReportVisitsDrugsBindingModel
{
public string FileName { get; set; } = string.Empty;
public List<int> Pets { get; set; } = new();
//public List<int> Pets { get; set; } = new();
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public int? OwnerId { get; set; }

View File

@ -20,7 +20,8 @@ namespace VeterinaryDatabaseImplement.Implements
{
using var context = new VeterinaryDatabase();
return context.Purchases.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Drug)
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
.Where(x => x.OwnerId == model.OwnerId)
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
(!model.DateCreate.HasValue || x.DateCreate >= model.DateCreate) &&
(!model.OwnerId.HasValue || x.OwnerId <= model.OwnerId) &&
(!model.DrugId.HasValue || x.DrugId == model.DrugId)))

View File

@ -21,7 +21,8 @@ namespace VeterinaryDatabaseImplement.Implements
using var context = new VeterinaryDatabase();
return context.Visits.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Doctor)
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
.Where(x => x.OwnerId == model.OwnerId)
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
(string.IsNullOrEmpty(model.VisitName) || x.VisitName.Contains(model.VisitName)) &&
(!model.DateVisit.HasValue || x.DateVisit >= model.DateVisit) &&
(!model.OwnerId.HasValue || x.OwnerId <= model.OwnerId) &&

View File

@ -76,8 +76,8 @@ namespace VeterinaryRestApi.Controllers
{
MailAddress = model.Email!,
Subject = "Отчет по животным",
Text = "Лови"
});
Text = "Отчет по животным"
});
}
catch (Exception ex)
{

View File

@ -199,7 +199,7 @@ namespace VeterinaryShowOwnerApp.Controllers
PetBreed = breed,
PetGender = gender,
});
Response.Redirect("Pets");
Response.Redirect("Index");
}
[HttpGet]
public Tuple<PetViewModel, List<string>>? GetPet(int petId)
@ -497,7 +497,7 @@ namespace VeterinaryShowOwnerApp.Controllers
table += "<tr>";
table += "<th scope=\"col\">Дата</th>";
table += "<th scope=\"col\">Животное</th>";
table += "<th scope=\"col\">Название визита</th>";
table += "<th scope=\"col\">Название посещенияы</th>";
table += "<th scope=\"col\">Лекарство</th>";
table += "</tr>";
table += "</thead>";
@ -542,9 +542,9 @@ namespace VeterinaryShowOwnerApp.Controllers
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIOwner.PostRequest("api/report/sendvisitsdrugsreporttoemail", new ReportVisitsDrugsBindingModel
APIOwner.PostRequest("api/reportowner/sendvisitsdrugsreporttoemail", new ReportVisitsDrugsBindingModel
{
FileName = "C:\\ReportsCourseWork\\pdffile.pdf",
FileName = "C:\\Users\\niyaz\\Downloads\\pdffile.pdf",
OwnerId = APIOwner.Owner.Id,
DateFrom = dateFrom,
DateTo = dateTo,