Реализована модель сущности диагноз для бд

This commit is contained in:
Никита Потапов 2024-04-28 12:53:41 +04:00
parent bc32dba8f9
commit 21d08fdfa1
3 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,50 @@
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.ViewModels;
using PolyclinicDataModels.Models;
using System.ComponentModel.DataAnnotations;
namespace PolyclinicDatabaseImplement.Models
{
public class Diagnose : IDiagnoseModel
{
[Required]
public string Name { get; private set; } = string.Empty;
[Required]
public string Comment { get; private set; } = string.Empty;
[Required]
public int UserId { get; private set; }
public int Id { get; private set; }
public static Diagnose? Create(DiagnoseBindingModel? model)
{
if (model == null)
{
return null;
}
return new Diagnose
{
Name = model.Name,
Comment = model.Comment,
UserId = model.UserId,
Id = model.Id
};
}
public void Update(DiagnoseBindingModel? model)
{
if (model == null)
{
return;
}
Name = model.Name;
Comment = model.Comment;
}
public DiagnoseViewModel GetViewModel => new()
{
Name = Name,
Comment = Comment,
UserId = UserId,
Id = Id
};
}
}

View File

@ -8,7 +8,6 @@
<ItemGroup> <ItemGroup>
<Folder Include="Implements\" /> <Folder Include="Implements\" />
<Folder Include="Models\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -16,4 +15,9 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.16" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.16" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PolyclinicContracts\PolyclinicContracts.csproj" />
<ProjectReference Include="..\PolyclinicDataModels\PolyclinicDataModels.csproj" />
</ItemGroup>
</Project> </Project>