2024-04-30 20:55:37 +04:00
|
|
|
|
using ServiceStationContracts.BindingModels;
|
|
|
|
|
using ServiceStationContracts.ViewModels;
|
2024-08-03 23:26:15 +04:00
|
|
|
|
using ServiceStationDataModels.Models;
|
2024-04-30 20:55:37 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2024-08-10 18:43:15 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2024-04-30 20:55:37 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace ServiceStationsDataBaseImplement.Models
|
|
|
|
|
{
|
2024-08-10 18:43:15 +04:00
|
|
|
|
public class Client : IClientModel {
|
2024-04-30 23:40:05 +04:00
|
|
|
|
|
2024-08-10 18:43:15 +04:00
|
|
|
|
public int Id { get; set; }
|
2024-04-30 23:40:05 +04:00
|
|
|
|
|
2024-08-10 18:43:15 +04:00
|
|
|
|
[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
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-04-30 20:55:37 +04:00
|
|
|
|
}
|