Merge branch 'stage7_user_web_interface_prototype' of https://git.is.ulstu.ru/ns.potapov/PIbd-21_CourseWork_Polyclinic_BeSick into stage7_user_web_interface_prototype
This commit is contained in:
commit
9b1aa7aa40
@ -12,10 +12,10 @@ namespace PolyclinicContracts.ViewModels
|
||||
public string Comment { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата 'от'")]
|
||||
public DateTime DateStartDiagnose { get; set; } = DateTime.Now;
|
||||
public DateTime DateStartDiagnose { get; set; }
|
||||
|
||||
[DisplayName("Дата 'до'")]
|
||||
public DateTime? DateStopDiagnose { get; set; } = DateTime.Now;
|
||||
public DateTime? DateStopDiagnose { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using PolyclinicContracts.BindingModels;
|
||||
using PolyclinicContracts.SearchModels;
|
||||
using PolyclinicContracts.StoragesContracts;
|
||||
@ -31,12 +32,36 @@ namespace PolyclinicDatabaseImplement.Implements
|
||||
public List<DiagnoseViewModel> GetFilteredList(DiagnoseSearchModel model)
|
||||
{
|
||||
var elements = GetFullList();
|
||||
foreach (var prop in model.GetType().GetProperties())
|
||||
if (model.Id != null)
|
||||
{
|
||||
if (model.GetType().GetProperty(prop.Name)?.GetValue(model, null) != null)
|
||||
{
|
||||
elements = elements.Where(x => x.GetType().GetProperty(prop.Name)?.GetValue(x, null) == model.GetType().GetProperty(prop.Name)?.GetValue(model, null)).ToList();
|
||||
}
|
||||
elements = elements.Where(x => x.Id == model.Id.Value).ToList();
|
||||
}
|
||||
if (!model.Name.IsNullOrEmpty())
|
||||
{
|
||||
elements = elements.Where(x => x.Name == model.Name).ToList();
|
||||
}
|
||||
if (model.UserId != null)
|
||||
{
|
||||
elements = elements.Where(x => x.UserId == model.UserId.Value).ToList();
|
||||
}
|
||||
if (model.From != null)
|
||||
{
|
||||
elements = elements.Where(x => x.DateStartDiagnose >= model.From.Value).ToList();
|
||||
}
|
||||
if (model.To != null)
|
||||
{
|
||||
elements = elements.Where(x => x.DateStartDiagnose <= model.To.Value).ToList();
|
||||
|
||||
var elemWithDateStop = elements
|
||||
.Where(x => x.DateStopDiagnose != null)
|
||||
.Where(x => x.DateStopDiagnose <= model.To.Value)
|
||||
.ToList();
|
||||
|
||||
var elemWithoutDateStop = elements.Where(x => x.DateStopDiagnose == null).ToList();
|
||||
|
||||
elemWithDateStop.AddRange(elemWithoutDateStop);
|
||||
|
||||
elements = elemWithDateStop;
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using PolyclinicContracts.BindingModels;
|
||||
using PolyclinicContracts.SearchModels;
|
||||
using PolyclinicContracts.StoragesContracts;
|
||||
@ -21,34 +22,44 @@ namespace PolyclinicDatabaseImplement.Implements
|
||||
|
||||
public List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.From.HasValue && !model.To.HasValue && !model.UserId.HasValue)
|
||||
var elements = GetFullList();
|
||||
if (model.Id != null)
|
||||
{
|
||||
return new();
|
||||
elements = elements.Where(x => x.Id == model.Id.Value).ToList();
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
if (model.UserId != null)
|
||||
{
|
||||
return new();
|
||||
elements = elements.Where(x => x.UserId == model.UserId.Value).ToList();
|
||||
}
|
||||
using var database = new PolyclinicDatabase();
|
||||
return database.Procedures
|
||||
.Where(x => x.Id == model.Id || x.Name == model.Name || x.DateStartProcedure <= model.To)
|
||||
.Include(p => p.User)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
if (!model.Name.IsNullOrEmpty())
|
||||
{
|
||||
elements = elements.Where(x => x.Name == model.Name).ToList();
|
||||
}
|
||||
if (model.From != null)
|
||||
{
|
||||
elements = elements.Where(x => x.DateStartProcedure >= model.From.Value).ToList();
|
||||
}
|
||||
if (model.To != null)
|
||||
{
|
||||
elements = elements.Where(x => x.DateStartProcedure <= model.To.Value).ToList();
|
||||
|
||||
var elemWithDateStop = elements
|
||||
.Where(x => x.DateStopProcedure != null)
|
||||
.Where(x => x.DateStopProcedure <= model.To.Value)
|
||||
.ToList();
|
||||
|
||||
var elemWithoutDateStop = elements.Where(x => x.DateStopProcedure == null).ToList();
|
||||
|
||||
elemWithDateStop.AddRange(elemWithoutDateStop);
|
||||
|
||||
elements = elemWithDateStop;
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
public ProcedureViewModel? GetElement(ProcedureSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var database = new PolyclinicDatabase();
|
||||
return database.Procedures
|
||||
.Include(p => p.User)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return GetFilteredList(model).FirstOrDefault();
|
||||
}
|
||||
|
||||
public ProcedureViewModel? Insert(ProcedureBindingModel model)
|
||||
|
Loading…
Reference in New Issue
Block a user