Исполнитель: дело было в слэше

This commit is contained in:
Yunusov_Niyaz 2024-05-03 00:39:40 +04:00
parent a1fbf73d7a
commit ae18ded13c
13 changed files with 63 additions and 50 deletions

View File

@ -1,4 +1,5 @@
using DocumentFormat.OpenXml.Presentation;
using DocumentFormat.OpenXml.EMMA;
using DocumentFormat.OpenXml.Presentation;
using VeterinaryBusinessLogic.OfficePackage;
using VeterinaryBusinessLogic.OfficePackage.HelperModels;
using VeterinaryContracts.BindingModels;
@ -12,64 +13,31 @@ namespace VeterinaryBusinessLogic.BusinessLogic
public class ReportLogicOwner : IReportLogicOwner
{
private readonly IPetStorage _petStorage;
private readonly IVisitStorage _visitStorage;
private readonly IServiceStorage _serviceStorage;
private readonly AbstractSaveToExcelOwner _saveToExcel;
private readonly AbstractSaveToWordOwner _saveToWord;
public ReportLogicOwner(IPetStorage petStorage, IVisitStorage visitStorage, IServiceStorage serviceStorage,
public ReportLogicOwner(IPetStorage petStorage,
AbstractSaveToExcelOwner saveToExcel, AbstractSaveToWordOwner saveToWord)
{
_petStorage = petStorage;
_visitStorage = visitStorage;
_serviceStorage = serviceStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
}
public List<ReportPetServicesViewModel> GetPetServices(List<int> pets)
public List<ReportPetServicesViewModel> GetPetServices(ReportServicesBindingModel model)
{
List<ReportPetServicesViewModel> servs = new();
List<Tuple<PetViewModel, List<Tuple<VisitViewModel, List<ServiceViewModel>>>>> response =
_petStorage.GetReportInfo(new ReportServicesSearchModel { petsIds = pets });
foreach (var pet in response)
{
Dictionary<int,(ServiceViewModel, int)> counter = new();
foreach (var visit in pet.Item2)
{
foreach (var service in visit.Item2)
{
if (!counter.ContainsKey(service.Id))
counter.Add(service.Id, (service, 1));
else
{
counter[service.Id] = (counter[service.Id].Item1, counter[service.Id].Item2 + 1);
}
}
}
List<ServiceViewModel> res = new();
foreach (var cont in counter)
{
if (cont.Value.Item2 != pet.Item2.Count)
continue;
res.Add(cont.Value.Item1);
}
servs.Add(new ReportPetServicesViewModel
{
PetName = pet.Item1.PetName,
Services = res
});
}
return servs;
return _petStorage.GetReportServices(new() { petsIds = model.Pets});
}
public List<ReportVisitsDrugsViewModel> GetVisitsDrugs(ReportVisitsDrugsBindingModel model)
{
return _petStorage.GetReportVisitsDrugs(new() { DateFrom = model.DateFrom, DateTo = model.DateTo });
}
public void SaveServicesToExcelFile(ReportServicesBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfoOwner
{
FileName = model.FileName,
Title = "Список услуг для животных",
PetServices = GetPetServices(model.Pets)
PetServices = GetPetServices(model)
});
}
@ -79,7 +47,7 @@ namespace VeterinaryBusinessLogic.BusinessLogic
{
FileName = model.FileName,
Title = "Список услуг для животных",
PetServices = GetPetServices(model.Pets)
PetServices = GetPetServices(model)
});
}
}

View File

@ -0,0 +1,10 @@
namespace VeterinaryContracts.BindingModels
{
public class ReportVisitsDrugsBindingModel
{
public string FileName { get; set; } = string.Empty;
public List<int> Pets { get; set; } = new();
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -5,7 +5,8 @@ namespace VeterinaryContracts.BusinessLogicContracts
{
public interface IReportLogicOwner
{
List<ReportPetServicesViewModel> GetPetServices(List<int> services);
List<ReportPetServicesViewModel> GetPetServices(ReportServicesBindingModel model);
List<ReportVisitsDrugsViewModel> GetVisitsDrugs(ReportVisitsDrugsBindingModel model);
void SaveServicesToWordFile(ReportServicesBindingModel model);
void SaveServicesToExcelFile(ReportServicesBindingModel model);
}

View File

@ -8,6 +8,5 @@
public string? PetType { get; set; }
public string? PetBreed { get; set; }
public string? PetGender { get; set; }
public int? VisitId { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace VeterinaryContracts.SearchModels
{
public class ReportVisitsDrugsSearchModel
{
public List<int>? petsIds { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -7,6 +7,5 @@
public int? DoctorId { get; set; }
public string? VisitName { get; set; }
public DateTime? DateVisit { get; set; }
public int? PetId { get; set; }
}
}

View File

@ -8,7 +8,8 @@ namespace VeterinaryContracts.StorageContracts
{
List<PetViewModel> GetFullList();
List<PetViewModel> GetFilteredList(PetSearchModel model);
public List<Tuple<PetViewModel, List<Tuple<VisitViewModel, List<ServiceViewModel>>>>> GetReportInfo(ReportServicesSearchModel model);
List<ReportPetServicesViewModel> GetReportServices(ReportServicesSearchModel model);
List<ReportVisitsDrugsViewModel> GetReportVisitsDrugs(ReportVisitsDrugsSearchModel model);
PetViewModel? GetElement(PetSearchModel model);
PetViewModel? Insert(PetBindingModel model);
PetViewModel? Update(PetBindingModel model);

View File

@ -17,7 +17,7 @@ namespace VeterinaryContracts.ViewModels
[DisplayName("Дата покупки")]
public DateTime DateCreate { get; set; }
[DisplayName("Дата завершения покупки")]
public DateTime DateImplement { get; set; }
public DateTime? DateImplement { get; set; }
public Dictionary<int, IPetModel> PurchasePet { get; set; } = new();
}
}

View File

@ -0,0 +1,9 @@
namespace VeterinaryContracts.ViewModels
{
public class ReportVisitsDrugsViewModel
{
string PetName { get; set; } = string.Empty;
List<VisitViewModel> Visits { get; set; }
List<DrugViewModel> Drugs { get; set; }
}
}

View File

@ -0,0 +1,11 @@
namespace VeterinaryContracts.ViewModels
{
public class VisitsDrugsViewModel
{
public string PetName { get; set; } = string.Empty;
public List<VisitViewModel> Visits { get; set; } = new();
public List<DrugViewModel> Drugs { get; set; } = new();
public DateTime DateFrom { get; set; } = DateTime.Now;
public DateTime DateTo { get; set; } = DateTime.Now;
}
}

View File

@ -42,7 +42,7 @@ namespace VeterinaryDatabaseImplement.Implements
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<ReportPetServicesViewModel> GetReportPetServicesList(ReportServicesSearchModel model)
public List<ReportPetServicesViewModel> GetReportServices(ReportServicesSearchModel model)
{
if (model.petsIds == null)
{
@ -58,6 +58,10 @@ namespace VeterinaryDatabaseImplement.Implements
.Where(service => service.Visit!=null&&service.Visit.Pets.Select(x => x.PetId).ToList().Contains(pet.Id))
.Select(service => service.GetViewModel).ToList()
}).ToList();
}
public List<ReportVisitsDrugsViewModel> GetReportVisitsDrugs(ReportVisitsDrugsSearchModel model)
{
}
public PetViewModel? Insert(PetBindingModel model)
{

View File

@ -12,6 +12,7 @@ namespace VeterinaryDatabaseImplement.Models
public int Id { get; private set; }
[Required]
public int OwnerId { get; private set; }
public virtual Owner? Owner { get; private set; }
[Required]
public string PetName { get; private set; } = string.Empty;
[Required]

View File

@ -22,7 +22,7 @@ namespace VeterinaryDatabaseImplement.Models
[Required]
public DateTime DateCreate { get; private set; }
[Required]
public DateTime DateImplement { get; private set; }
public DateTime? DateImplement { get; private set; }
private Dictionary<int, IPetModel>? _purchasePet = null;
[NotMapped]
public Dictionary<int, IPetModel> PurchasePet
@ -50,6 +50,7 @@ namespace VeterinaryDatabaseImplement.Models
OwnerId = model.OwnerId,
DrugId = model.DrugId,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement,
Pets = model.PurchasePet.Select(x => new PurchasePet
{
Pet = context.Pets.First(y => y.Id == x.Key),