59 lines
1.3 KiB
C#
59 lines
1.3 KiB
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;
|
|
|
|
[Required]
|
|
public string Password { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Login { 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,
|
|
Password = model.Password,
|
|
Login = model.Login
|
|
};
|
|
}
|
|
|
|
public void Update (ClientBindingModel? model) {
|
|
if (model == null) {
|
|
return;
|
|
}
|
|
FIO = model.FIO;
|
|
Login = model.Login;
|
|
Password = model.Password;
|
|
}
|
|
|
|
public ClientViewModel GetViewModel => new() {
|
|
Id = Id,
|
|
FIO = FIO,
|
|
Password = Password,
|
|
Login = Login
|
|
};
|
|
}
|
|
}
|