CourseWork_BankYouBankrupt/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Client.cs

76 lines
2.0 KiB
C#
Raw Normal View History

2023-04-01 16:30:10 +04:00
using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Models;
2023-04-01 15:33:39 +04:00
using System;
using System.Collections.Generic;
2023-04-01 16:30:10 +04:00
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
2023-04-01 15:33:39 +04:00
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankYouBankruptDatabaseImplement.Models
{
public class Client : IClientModel
{
2023-04-01 16:30:10 +04:00
public int Id { get; set; }
2023-04-01 15:33:39 +04:00
2023-04-01 16:30:10 +04:00
[Required]
public string Name { get; set; } = string.Empty;
2023-04-01 15:33:39 +04:00
2023-04-01 16:30:10 +04:00
[Required]
public string Surname { get; set; } = string.Empty;
2023-04-01 15:33:39 +04:00
2023-04-01 16:30:10 +04:00
[Required]
public string Patronymic { get; set; } = string.Empty;
2023-04-01 15:33:39 +04:00
2023-04-01 16:30:10 +04:00
[Required]
public string Telephone { get; set; } = string.Empty;
2023-04-01 15:33:39 +04:00
2023-04-01 16:30:10 +04:00
[Required]
public string Email { get; set; } = string.Empty;
2023-04-01 15:33:39 +04:00
2023-04-01 16:30:10 +04:00
[Required]
public string Password { get; set; } = string.Empty;
2023-04-01 16:36:07 +04:00
[ForeignKey("ClientID")]
public virtual List<Card> Cards { get; set; } = new();
2023-04-01 16:30:10 +04:00
public ClientViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Surname = Surname,
Patronymic = Patronymic,
Telephone = Telephone,
Email = Email,
Password = Password
};
public static Client Create(ClientBindingModel model)
{
return new Client()
{
Id = model.Id,
Name = model.Name,
Surname = model.Surname,
Patronymic = model.Patronymic,
Telephone = model.Telephone,
Email = model.Email,
Password = model.Password
};
}
public void Update(ClientBindingModel model)
{
Name = model.Name;
Surname = model.Surname;
Patronymic = model.Patronymic;
Telephone = model.Telephone;
Email = model.Email;
Password = model.Password;
}
2023-04-01 15:33:39 +04:00
}
}
2023-04-01 16:30:10 +04:00