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

56 lines
1.5 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 From { get; set; } = DateTime.Now;
public DateTime? To { get; set; }
[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,
From = bindingModel.From,
To = bindingModel.To,
};
}
public void Update(ProcedureBindingModel bindingModel)
{
Name = bindingModel.Name;
Comment = bindingModel.Comment;
}
public ProcedureViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
UserId = UserId,
Comment = Comment,
From = From,
To = To,
};
}
}