71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using HospitalDataModels.Models;
|
|
using HospitalContracts.BindingModels;
|
|
using HospitalContracts.ViewModels;
|
|
|
|
namespace HospitalDataBaseImplements.Models
|
|
{
|
|
public class Kurses : IKurseModel
|
|
{
|
|
public int Id { get; private set; }
|
|
public int MedicinesId { get; private set; }
|
|
public string MedicinesName { get; private set; } = string.Empty;
|
|
[Required]
|
|
public string Duration { get; private set; } = string.Empty;
|
|
[Required]
|
|
public int CountInDay { get; private set; }
|
|
[ForeignKey("DrugCourseId")]
|
|
public virtual List<IllnessKurse> IllnessKurses { get; set; } = new();
|
|
public static Kurses? Create(KurseBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Kurses()
|
|
{
|
|
Id = model.Id,
|
|
MedicinesId = model.MedicinesId,
|
|
MedicinesName = model.MedicinesName,
|
|
Duration = model.Duration,
|
|
CountInDay = model.CountInDay
|
|
};
|
|
}
|
|
public static Kurses Create(KurseViewModel model)
|
|
{
|
|
return new Kurses
|
|
{
|
|
Id = model.Id,
|
|
MedicinesId = model.MedicinesId,
|
|
MedicinesName = model.MedicinesName,
|
|
Duration = model.Duration,
|
|
CountInDay = model.CountInDay
|
|
};
|
|
}
|
|
public void Update(KurseBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
MedicinesName = model.MedicinesName;
|
|
Duration = model.Duration;
|
|
CountInDay = model.CountInDay;
|
|
}
|
|
public KurseViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
MedicinesId = MedicinesId,
|
|
MedicinesName = MedicinesName,
|
|
Duration = Duration,
|
|
CountInDay = CountInDay
|
|
};
|
|
}
|
|
}
|