PIbd-21_CourseWork_Polyclin.../Polyclinic/PolyclinicDatabaseImplement/Models/Procedure.cs

57 lines
1.7 KiB
C#

using PolyclinicContracts.BindingModels;
using PolyclinicContracts.ViewModels;
using PolyclinicDataModels.Models;
using SecuritySystemDatabaseImplement;
using System.ComponentModel.DataAnnotations;
namespace PolyclinicDatabaseImplement.Models
{
public class Procedure : IProcedureModel
{
public int Id { get; set; }
[Required]
public int UserId { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
[Required]
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;
public static Procedure Create(ProcedureBindingModel bindingModel)
{
return new Procedure()
{
Id = bindingModel.Id,
UserId = bindingModel.UserId,
Name = bindingModel.Name,
Comment = bindingModel.Comment,
DateStartProcedure = bindingModel.DateStartProcedure,
DateStopProcedure = bindingModel.DateStopProcedure,
};
}
public void Update(ProcedureBindingModel bindingModel)
{
Name = bindingModel.Name;
Comment = bindingModel.Comment;
}
public ProcedureViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
UserId = UserId,
Comment = Comment,
DateStartProcedure = DateStartProcedure,
DateStopProcedure = DateStopProcedure,
};
}
}