2024-05-01 01:54:31 +04:00

77 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BankContracts.BindingModels.Client;
using BankContracts.ViewModels.Client.ViewModels;
using BankDataModels.Models.Client;
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 BankDatabaseImplement.Models.ClientModels
{
// Класс, реализующий интерфейс модели клиента
public class Client : IClientModel
{
public int Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public string Surname { get; set; } = string.Empty;
[Required]
public string Patronymic { get; set; } = string.Empty;
[Required]
public string Email { get; set; } = string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
[Required]
public string MobilePhone { get; set; } = string.Empty;
// Для реализации связи один-ко-многим с банковскими картами
[ForeignKey("ClientId")]
public virtual List<Card> Cards { get; set; } = new();
public ClientViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Surname = Surname,
Patronymic = Patronymic,
Email = Email,
Password = Password,
MobilePhone = MobilePhone
};
public static Client Create(ClientBindingModel model)
{
return new Client()
{
Id = model.Id,
Name = model.Name,
Surname = model.Surname,
Patronymic = model.Patronymic,
Email = model.Email,
Password = model.Password,
MobilePhone = model.MobilePhone,
};
}
public void Update(ClientBindingModel model)
{
Name = model.Name;
Surname = model.Surname;
Patronymic = model.Patronymic;
Email = model.Email;
Password = model.Password;
MobilePhone = model.MobilePhone;
}
}
}