2024-04-28 18:13:52 +04:00
|
|
|
|
using PolyclinicContracts.BindingModels;
|
|
|
|
|
using PolyclinicContracts.ViewModels;
|
|
|
|
|
using PolyclinicDataModels.Models;
|
|
|
|
|
using SecuritySystemDatabaseImplement;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2024-04-28 16:24:52 +04:00
|
|
|
|
|
|
|
|
|
namespace PolyclinicDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Procedure : IProcedureModel
|
|
|
|
|
{
|
2024-04-28 18:13:52 +04:00
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public int UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
2024-04-30 16:20:00 +04:00
|
|
|
|
public string Name { get; set; } = string.Empty;
|
2024-04-28 18:13:52 +04:00
|
|
|
|
|
2024-05-01 00:48:45 +04:00
|
|
|
|
[Required]
|
2024-05-01 10:33:00 +04:00
|
|
|
|
public DateTime DateStartProcedure { get; set; } = DateTime.Now;
|
|
|
|
|
public DateTime? DateStopProcedure { get; set; }
|
2024-05-29 13:55:20 +04:00
|
|
|
|
public virtual User? User { get; set; }
|
2024-05-01 00:48:45 +04:00
|
|
|
|
|
2024-05-28 19:59:22 +04:00
|
|
|
|
public string? Comment { get; set; } = string.Empty;
|
2024-04-28 18:13:52 +04:00
|
|
|
|
|
2024-05-28 19:59:22 +04:00
|
|
|
|
public static Procedure? Create(ProcedureBindingModel bindingModel)
|
2024-04-28 18:13:52 +04:00
|
|
|
|
{
|
|
|
|
|
return new Procedure()
|
|
|
|
|
{
|
|
|
|
|
Id = bindingModel.Id,
|
|
|
|
|
UserId = bindingModel.UserId,
|
|
|
|
|
Name = bindingModel.Name,
|
|
|
|
|
Comment = bindingModel.Comment,
|
2024-05-01 10:33:00 +04:00
|
|
|
|
DateStartProcedure = bindingModel.DateStartProcedure,
|
|
|
|
|
DateStopProcedure = bindingModel.DateStopProcedure,
|
2024-04-28 18:13:52 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 19:09:14 +04:00
|
|
|
|
public void Update(ProcedureBindingModel? bindingModel)
|
2024-04-28 18:13:52 +04:00
|
|
|
|
{
|
2024-05-27 19:09:14 +04:00
|
|
|
|
if (bindingModel == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-04-28 18:13:52 +04:00
|
|
|
|
Name = bindingModel.Name;
|
|
|
|
|
Comment = bindingModel.Comment;
|
2024-05-27 19:09:14 +04:00
|
|
|
|
DateStartProcedure = bindingModel.DateStartProcedure;
|
|
|
|
|
DateStopProcedure = bindingModel.DateStopProcedure;
|
2024-04-28 18:13:52 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ProcedureViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Name = Name,
|
|
|
|
|
UserId = UserId,
|
|
|
|
|
Comment = Comment,
|
2024-05-01 10:33:00 +04:00
|
|
|
|
DateStartProcedure = DateStartProcedure,
|
|
|
|
|
DateStopProcedure = DateStopProcedure,
|
2024-04-30 16:20:00 +04:00
|
|
|
|
};
|
2024-04-28 16:24:52 +04:00
|
|
|
|
}
|
|
|
|
|
}
|