Compare commits

..

No commits in common. "51cc93b256cc681cf397fa0af80c872211206bf3" and "99ca054c53c0880f92bfbff0ec30cb66d55116b1" have entirely different histories.

13 changed files with 7 additions and 171 deletions

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VetClinicContracts.BindingModels
{
public class ListServicesBindingModel
{
public string FileName { get; set; } = string.Empty;
public List<int> Animals { get; set; } = new();
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VetClinicContracts.BindingModels
{
public class MedicineVaccinationsBindingModel
{
public string FileName { get; set; } = string.Empty;
public List<int> Visits { get; set; } = new();
DateTime DateFrom { get; set; } = DateTime.Now;
DateTime DateTo { get; set; } = DateTime.Now;
}
}

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VetClinicContracts.BindingModels;
using VetClinicContracts.ViewModels;
namespace VetClinicContracts.BusinessLogicsContracts
{
public interface IReportLogicAdmin //Будет дорабатываться
{
List<ListAnimalsViewModel> GetServiceAnimals(List<int> animals);
void SaveServicesToWordFile(ListServicesBindingModel model);
void SaveServicesToExcelFile(ListServicesBindingModel model);
}
}

View File

@ -13,5 +13,6 @@ namespace VetClinicContracts.SearchModels
public int? AdminId { get; set; }
public string? AnimalName { get; set; }
public string? Family { get; set; }
public int? MedicineId { get; set; }
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VetClinicContracts.SearchModels
{
public class ListServicesSearchModel
{
public List<int>? animalsIds { get; set; }
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VetClinicContracts.SearchModels
{
public class MedicineVaccinationsSearchModel
{
public List<int>? visitsIds { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -16,5 +16,6 @@ namespace VetClinicContracts.SearchModels
public string? DateVisit { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public int? ServiceId { get; set; }
}
}

View File

@ -13,7 +13,6 @@ namespace VetClinicContracts.StoragesContracts
{
List<AnimalViewModel> GetFullList();
List<AnimalViewModel> GetFilteredList(AnimalSearchModel model);
List<Tuple<AnimalViewModel, List<Tuple<MedicineViewModel, List<ServiceViewModel>>>>> GetReportInfo(ListServicesSearchModel model);
AnimalViewModel? GetElement(AnimalSearchModel model);
AnimalViewModel? Insert(AnimalBindingModel model);
AnimalViewModel? Update(AnimalBindingModel model);

View File

@ -13,10 +13,6 @@ namespace VetClinicContracts.StoragesContracts
{
List<VisitViewModel> GetFullList();
List<VisitViewModel> GetFilteredList(VisitSearchModel model);
public List<Tuple<VisitViewModel, List<Tuple<AnimalViewModel, List<VaccinationViewModel>>>>> GetVaccinationsInfo(MedicineVaccinationsSearchModel model);
public List<Tuple<VisitViewModel, List<Tuple<AnimalViewModel, List<MedicineViewModel>>>>> GetMedicinesInfo(MedicineVaccinationsSearchModel model);
VisitViewModel? GetElement(VisitSearchModel model);
VisitViewModel? Insert(VisitBindingModel model);
VisitViewModel? Update(VisitBindingModel model);

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VetClinicContracts.ViewModels
{
public class ListServicesViewModel
{
public string ServiceName { get; set; } = string.Empty;
public List<ServiceViewModel> Services { get; set; } = new();
}
}

View File

@ -1,18 +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 MedicineVaccinationViewModel
{
public string VisitName { get; set; } = string.Empty;
public List<MedicineViewModel> Medicines { get; set; } = new();
public List<VaccinationViewModel> Vaccinations { get; set; } = new();
public DateTime DateFrom { get; set; } = DateTime.Now;
public DateTime DateTo { get; set; } = DateTime.Now;
}
}

View File

@ -5,7 +5,6 @@ using VetClinicContracts.ViewModels;
using VetClinicDataBaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using VetClinicDataBaseImplement;
using System.Linq;
namespace VetClinicBaseImplement.Implements
{
@ -29,28 +28,11 @@ namespace VetClinicBaseImplement.Implements
return context.Animals.Include(x => x.Admin).Include(x => x.Visits)
.ThenInclude(x => x.Visit).Include(x => x.Medicines).ThenInclude(x => x.Medicine)
.Where(x => (string.IsNullOrEmpty(model.AnimalName) || x.AnimalName.Contains(model.AnimalName))
&& (!model.AdminId.HasValue || x.AdminId == model.AdminId))
&& (!model.AdminId.HasValue || x.AdminId == model.AdminId)
&& (!model.MedicineId.HasValue || x.Medicines.Select(x => x.MedicineId).ToList().Contains(model.MedicineId.Value)))
.Select(x => x.GetViewModel)
.ToList();
}
public List<Tuple<AnimalViewModel, List<Tuple<MedicineViewModel, List<ServiceViewModel>>>>> GetReportInfo(ListServicesSearchModel model)
{
if (model.animalsIds == null)
{
return new();
}
using var context = new VetClinicDatabase();
return context.Animals
.Where(animal => model.animalsIds.Contains(animal.Id))
.Select(animal => new Tuple<AnimalViewModel, List<Tuple<MedicineViewModel, List<ServiceViewModel>>>>(animal.GetViewModel,
context.MedicineAnimals.Include(medicine => medicine.Medicine)
.Include(medicine => medicine.Animal).Where(medicine => animal.Id == medicine.AnimalId).
Select(medicine => new Tuple<MedicineViewModel, List<ServiceViewModel>>(medicine.Medicine.GetViewModel,
context.ServiceMedicines.Include(x => x.Service).Where(x => x.MedicineId == medicine.Medicine.Id).
Select(x => x.Service.GetViewModel).ToList())).ToList())).ToList();
}
public AnimalViewModel? GetElement(AnimalSearchModel model)
{
if (!model.Id.HasValue)

View File

@ -31,49 +31,13 @@ namespace VetClinicDataBaseImplement.Implements
{
using var context = new VetClinicDatabase();
return context.Visits.Include(x => x.Admin).Include(x => x.Services)
.ThenInclude(x => x.Service).Include(x => x.Animals).ThenInclude(x => x.Animal)
.ThenInclude(x => x.Service)
.Where(x => (string.IsNullOrEmpty(model.NameVisit) || x.NameVisit.Contains(model.NameVisit))
&& (!model.AdminId.HasValue || x.AdminId == model.AdminId))
&& (!model.AdminId.HasValue || x.AdminId == model.AdminId)
&& (!model.ServiceId.HasValue || x.Services.Select(x => x.ServiceId).ToList().Contains(model.ServiceId.Value)))
.Select(x => x.GetViewModel)
.ToList();
}
public List<Tuple<VisitViewModel, List<Tuple<AnimalViewModel, List<VaccinationViewModel>>>>> GetVaccinationsInfo(MedicineVaccinationsSearchModel model)
{
if (model.visitsIds == null)
{
return new();
}
using var context = new VetClinicDatabase();
return context.Visits
.Where(visit => model.visitsIds.Contains(visit.Id))
.Select(visit => new Tuple<VisitViewModel, List<Tuple<AnimalViewModel, List<VaccinationViewModel>>>>(visit.GetViewModel,
context.VisitAnimals.Include(animal => animal.Animal)
.Include(animal => animal.Visit).Where(animal => visit.Id == animal.VisitId).
Select(animal => new Tuple<AnimalViewModel, List<VaccinationViewModel>>(animal.Animal.GetViewModel,
context.Vaccinations.Include(x => x.Animal).Where(x => x.AnimalId == animal.AnimalId && x.DateStamp >= model.DateFrom && x.DateStamp <= model.DateTo).
Select(x => x.GetViewModel).ToList())).ToList())).ToList();
}
public List<Tuple<VisitViewModel, List<Tuple<AnimalViewModel, List<MedicineViewModel>>>>> GetMedicinesInfo(MedicineVaccinationsSearchModel model)
{
if (model.visitsIds == null)
{
return new();
}
using var context = new VetClinicDatabase();
return context.Visits
.Where(visit => model.visitsIds.Contains(visit.Id))
.Select(visit => new Tuple<VisitViewModel, List<Tuple<AnimalViewModel, List<MedicineViewModel>>>>(visit.GetViewModel,
context.VisitAnimals.Include(animal => animal.Animal)
.Include(animal => animal.Visit).Where(animal => visit.Id == animal.VisitId).
Select(animal => new Tuple<AnimalViewModel, List<MedicineViewModel>>(animal.Animal.GetViewModel,
context.MedicineAnimals.Include(x => x.Medicine).Where(x => x.AnimalId == animal.AnimalId).
Select(x => x.Medicine.GetViewModel).ToList())).ToList())).ToList();
}
public VisitViewModel? GetElement(VisitSearchModel model)
{
if (!model.Id.HasValue)