51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
using DataContracts.bindingModels;
|
|
using DataContracts.models;
|
|
using DataContracts.viewModels;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Reflection;
|
|
|
|
namespace DatabaseImplement.models
|
|
{
|
|
public class Client : IClient
|
|
{
|
|
public int Id { get; set; }
|
|
[Required]
|
|
public string FIO { get; set; } = string.Empty;
|
|
[Required]
|
|
public byte[] photo { get; set; } = new byte[0];
|
|
[Required]
|
|
public string email { get; set; } = string.Empty;
|
|
public string products { get; set; } = string.Empty;
|
|
|
|
public static Client Create(ClientBindingModel model)
|
|
{
|
|
return new Client()
|
|
{
|
|
Id = model.Id,
|
|
FIO = model.FIO,
|
|
photo = model.photo,
|
|
email = model.email,
|
|
products = model.products
|
|
};
|
|
}
|
|
|
|
public void Update(ClientBindingModel model)
|
|
{
|
|
FIO = model.FIO;
|
|
email = model.email;
|
|
photo = model.photo;
|
|
products = model.products;
|
|
}
|
|
|
|
public ClientViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
FIO = FIO,
|
|
photo = photo,
|
|
email = email,
|
|
products = products
|
|
};
|
|
|
|
}
|
|
} |