64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
|
using CaseAccountingContracts.BindingModels;
|
|||
|
using CaseAccountingContracts.ViewModels;
|
|||
|
using CaseAccountingDataModels.Models;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using System.ComponentModel.DataAnnotations.Schema;
|
|||
|
using System.Linq;
|
|||
|
using System.Net;
|
|||
|
using System.Security.Cryptography.X509Certificates;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace CaseAccountingDataBaseImplement.Models
|
|||
|
{
|
|||
|
public class Specialization : ISpecializationModel
|
|||
|
{
|
|||
|
public int Id { get; set; }
|
|||
|
|
|||
|
[Required]
|
|||
|
public string Name { get; set; } = string.Empty;
|
|||
|
|
|||
|
[Required]
|
|||
|
public int UserId { get; set; }
|
|||
|
public virtual User User { get; set; } = new();
|
|||
|
|
|||
|
[ForeignKey("SpecializationId")]
|
|||
|
public virtual List<Lawyer> Lawyers { get; set; } = new();
|
|||
|
|
|||
|
[ForeignKey("SpecializationId")]
|
|||
|
public virtual List<Case> Cases { get; set; } = new();
|
|||
|
|
|||
|
public static Specialization? Create (SpecializationBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Specialization()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
Name = model.Name,
|
|||
|
UserId = model.UserId,
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(SpecializationBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
Name = model.Name;
|
|||
|
}
|
|||
|
|
|||
|
public SpecializationViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
Name = Name,
|
|||
|
UserId = UserId
|
|||
|
};
|
|||
|
}
|
|||
|
}
|