добавила дату в реализацию хранилища у процедуры, без реализации в хранилище добавила дату в диагнозы

This commit is contained in:
Елена Бакальская 2024-05-01 10:33:00 +04:00
parent 0459cc754e
commit 0e1ca068bd
11 changed files with 45 additions and 16 deletions

View File

@ -8,5 +8,7 @@ namespace PolyclinicContracts.BindingModels
public string Comment { get; set; } = string.Empty;
public int UserId { get; set; }
public int Id { get; set; }
public DateTime DateStartDiagnose { get; }
public DateTime? DateStopDiagnose { get; }
}
}

View File

@ -8,8 +8,8 @@ namespace PolyclinicContracts.BindingModels
public int UserId { get; set; }
public string Name { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty;
public DateTime From { get; set; } = DateTime.Now;
public DateTime? To { get; set; }
public DateTime DateStartProcedure { get; set; } = DateTime.Now;
public DateTime? DateStopProcedure { get; set; }
}
}

View File

@ -5,5 +5,7 @@
public int? Id { get; set; }
public string? Name { get; set; }
public int? UserId { get; set; }
public DateTime? From { get; }
public DateTime? To { get; }
}
}

View File

@ -3,6 +3,7 @@
public class ProcedureSearchModel
{
public int? Id { get; set; }
public int? UserId { get; set; }
public string? Name { get; set; }
public DateTime? From { get; set; }
public DateTime? To { get; set; }

View File

@ -7,8 +7,15 @@ namespace PolyclinicContracts.ViewModels
{
[DisplayName("Название")]
public string Name { get; set; } = string.Empty;
[DisplayName("Комментарий")]
public string Comment { get; set; } = string.Empty;
[DisplayName("Дата 'от'")]
public DateTime DateStartDiagnose { get; set; } = DateTime.Now;
[DisplayName("Дата 'до'")]
public DateTime? DateStopDiagnose { get; set; } = DateTime.Now;
public int UserId { get; set; }
public int Id { get; set; }
}

View File

@ -15,9 +15,9 @@ namespace PolyclinicContracts.ViewModels
public string Comment { get; set; } = string.Empty;
[DisplayName("Дата 'от'")]
public DateTime From { get; set; } = DateTime.Now;
public DateTime DateStartProcedure { get; set; } = DateTime.Now;
[DisplayName("Дата 'до'")]
public DateTime? To { get; set; } = DateTime.Now;
public DateTime? DateStopProcedure { get; set; } = DateTime.Now;
}
}

View File

@ -5,5 +5,7 @@
string Name { get; }
string Comment { get; }
int UserId { get; }
DateTime DateStartDiagnose { get; }
DateTime? DateStopDiagnose { get; }
}
}

View File

@ -5,7 +5,7 @@
string Name { get; }
string Comment { get; }
int UserId { get; }
DateTime From { get; }
DateTime? To { get; }
DateTime DateStartProcedure { get; }
DateTime? DateStopProcedure { get; }
}
}

View File

@ -14,20 +14,25 @@ namespace PolyclinicDatabaseImplement.Implements
{
using var database = new PolyclinicDatabase();
return database.Procedures
.ToList()
.Include(p => p.User)
.Select(x => x.GetViewModel)
.ToList();
}
public List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model)
{
if (!model.Id.HasValue && !model.From.HasValue && !model.To.HasValue && !model.UserId.HasValue)
{
return new();
}
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var database = new PolyclinicDatabase();
return database.Procedures
.Where(x => x.Name == model.Name)
.Where(x => x.Id == model.Id || x.Name == model.Name || x.DateStartProcedure <= model.To)
.Include(p => p.User)
.Select(x => x.GetViewModel)
.ToList();
}
@ -41,6 +46,7 @@ namespace PolyclinicDatabaseImplement.Implements
}
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;
}

View File

@ -13,6 +13,10 @@ namespace PolyclinicDatabaseImplement.Models
public string Comment { get; set; } = string.Empty;
[Required]
public int UserId { get; set; }
[Required]
public DateTime DateStartDiagnose { get; set; } = DateTime.Now;
public DateTime? DateStopDiagnose { get; set; }
public int Id { get; set; }
public virtual User User { get; set; } = new();
@ -27,7 +31,9 @@ namespace PolyclinicDatabaseImplement.Models
Name = model.Name,
Comment = model.Comment,
UserId = model.UserId,
Id = model.Id
Id = model.Id,
DateStartDiagnose = model.DateStartDiagnose,
DateStopDiagnose = model.DateStopDiagnose,
};
}
@ -46,7 +52,9 @@ namespace PolyclinicDatabaseImplement.Models
Name = Name,
Comment = Comment,
UserId = UserId,
Id = Id
Id = Id,
DateStartDiagnose = DateStartDiagnose,
DateStopDiagnose = DateStopDiagnose,
};
}
}

View File

@ -17,8 +17,9 @@ namespace PolyclinicDatabaseImplement.Models
public string Name { get; set; } = string.Empty;
[Required]
public DateTime From { get; set; } = DateTime.Now;
public DateTime? To { get; set; }
public DateTime DateStartProcedure { get; set; } = DateTime.Now;
public DateTime? DateStopProcedure { get; set; }
public virtual User User { get; set; } = new();
[Required]
public string Comment { get; set; } = string.Empty;
@ -31,8 +32,8 @@ namespace PolyclinicDatabaseImplement.Models
UserId = bindingModel.UserId,
Name = bindingModel.Name,
Comment = bindingModel.Comment,
From = bindingModel.From,
To = bindingModel.To,
DateStartProcedure = bindingModel.DateStartProcedure,
DateStopProcedure = bindingModel.DateStopProcedure,
};
}
@ -48,8 +49,8 @@ namespace PolyclinicDatabaseImplement.Models
Name = Name,
UserId = UserId,
Comment = Comment,
From = From,
To = To,
DateStartProcedure = DateStartProcedure,
DateStopProcedure = DateStopProcedure,
};
}
}