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

43 lines
1.1 KiB
C#
Raw Normal View History

using PolyclinicContracts.BindingModels;
using PolyclinicContracts.ViewModels;
using PolyclinicDataModels.Models;
using SecuritySystemDatabaseImplement;
using System.ComponentModel.DataAnnotations;
namespace PolyclinicDatabaseImplement.Models
{
public class Recipe : IRecipeModel
{
public int Id { get; set; }
[Required]
public int ProceduresCount { get; set; }
[Required]
public string Comment { get; set; } = string.Empty;
public static Recipe Create( RecipeBindingModel bindingModel)
{
return new Recipe()
{
Id = bindingModel.Id,
ProceduresCount = bindingModel.ProceduresCount,
Comment = bindingModel.Comment,
};
}
public void Update(RecipeBindingModel bindingModel)
{
ProceduresCount = bindingModel.ProceduresCount;
Comment = bindingModel.Comment;
}
public RecipeViewModel GetViewModel => new()
{
Id = Id,
ProceduresCount = ProceduresCount,
Comment = Comment
};
}
}