Исправление бд
This commit is contained in:
parent
968d0e468c
commit
01197420c0
@ -9,6 +9,6 @@ namespace HospitalContracts.SearchModels
|
||||
public class KurseSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? MedicinesId { get; set; }
|
||||
public string? MedicinesName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,5 +10,7 @@ namespace HospitalContracts.SearchModels
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,10 @@ namespace HospitalDataBaseImplements.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Kurse.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
return context.Kurse
|
||||
.Where(x => x.MedicinesName.Contains(model.MedicinesName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<KurseViewModel> GetFullList()
|
||||
|
@ -39,12 +39,33 @@ namespace HospitalDataBaseImplements.Implements
|
||||
|
||||
public List<RecipesViewModel> GetFilteredList(RecipesSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
if (!model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Recipes.Include(x => x.Client).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
if (model.DateFrom.HasValue)
|
||||
{
|
||||
return context.Recipes
|
||||
.Include(x => x.Medicines)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.Date >= model.DateFrom && x.Date <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.ClientId.HasValue)
|
||||
return context.Recipes
|
||||
.Include(x => x.Medicines)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
return context.Recipes
|
||||
.Include(x => x.Medicines)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<RecipesViewModel> GetFullList()
|
||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace HospitalDataBaseImplements.Migrations
|
||||
{
|
||||
[DbContext(typeof(HospitalDatabase))]
|
||||
[Migration("20230406204404_InitialCreate")]
|
||||
[Migration("20230407072756_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
Loading…
Reference in New Issue
Block a user