Rogashova_E.A._CourseWork_H.../HospitalDataBaseImplements/Models/Procedures.cs

59 lines
1.6 KiB
C#

using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDataBaseImplements.Models
{
public class Procedures: IProceduresModel
{
public int Id { get; private set; }
[Required]
public string ProceduresName { get; private set; } = string.Empty;
[Required]
public string Type { get; private set; } = string.Empty;
public static Procedures? Create(ProceduresBindingModel model)
{
if (model == null)
{
return null;
}
return new Procedures()
{
Id = model.Id,
ProceduresName = model.ProceduresName,
Type = model.Type
};
}
public static Procedures Create(ProceduresViewModel model)
{
return new Procedures
{
Id = model.Id,
ProceduresName = model.ProceduresName,
Type = model.Type
};
}
public void Update(ProceduresBindingModel model)
{
if (model == null)
{
return;
}
ProceduresName = model.ProceduresName;
Type = model.Type;
}
public ProceduresViewModel GetViewModel => new()
{
Id = Id,
ProceduresName = ProceduresName,
Type = Type
};
}
}