2024-08-27 16:29:09 +04:00

47 lines
1009 B
C#

using ServiceStationContracts.BindingModels;
using ServiceStationContracts.ViewModels;
using ServiceStationDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceStationsDataBaseImplement.Models
{
public class Client : IClientModel {
public int Id { get; set; }
[Required]
public string FIO { get; set; } = string.Empty;
[ForeignKey("ClientId")]
public virtual List<WorkClient> WorkClients { get; set; } = new();
public static Client? Create(ClientBindingModel? model) {
if (model == null) {
return null;
}
return new Client() {
Id = model.Id,
FIO = model.FIO,
};
}
public void Update (ClientBindingModel? model) {
if (model == null) {
return;
}
FIO = model.FIO;
}
public ClientViewModel GetViewModel => new() {
Id = Id,
FIO = FIO
};
}
}