Case_accounting/CaseAccounting/CaseAccountingDataBaseImplement/Models/Hearing.cs
2023-04-07 16:35:57 +04:00

68 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.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingDataBaseImplement.Models
{
public class Hearing : IHearingModel
{
public int Id { get; set; }
[Required]
public string Information { get; set; } = string.Empty;
[Required]
public DateTime Date { get; set; }
[Required]
public int CaseId { get; set; }
public virtual Case Case { get; set; } = new();
[Required]
public int UserId { get; set; }
public virtual User User { get; set; } = new();
public static Hearing? Create (HearingBindingModel? model)
{
if (model == null)
{
return null;
}
return new Hearing()
{
Id = model.Id,
Information = model.Information,
Date = model.Date,
CaseId = model.CaseId,
UserId = model.UserId
};
}
public void Update (HearingBindingModel? model)
{
if (model == null)
{
return;
}
Information = model.Information;
Date = model.Date;
}
public HearingViewModel GetViewModel => new()
{
Id = Id,
Information = Information,
Date = Date,
CaseId = CaseId,
UserId = UserId
};
}
}