Исправление бд

This commit is contained in:
Екатерина Рогашова 2023-04-07 11:31:56 +04:00
parent 968d0e468c
commit 01197420c0
6 changed files with 31 additions and 5 deletions

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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()

View File

@ -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()

View File

@ -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 />