CourseWork_BankYouBankrupt/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Cashier.cs

86 lines
2.3 KiB
C#
Raw Normal View History

using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Models;
2023-04-01 15:33:39 +04:00
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
2023-04-01 15:33:39 +04:00
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankYouBankruptDatabaseImplement.Models
{
public class Cashier : ICashierModel
{
public int Id { get; set; }
2023-04-01 15:33:39 +04:00
[Required]
public string Password { get; set; } = string.Empty;
2023-04-01 15:33:39 +04:00
[Required]
public string Name { get; set; } = string.Empty;
2023-04-01 15:33:39 +04:00
[Required]
public string Surname { get; set; } = string.Empty;
2023-04-01 15:33:39 +04:00
[Required]
public string Patronymic { get; set; } = string.Empty;
2023-04-01 15:33:39 +04:00
[Required]
public string Email { get; set; } = string.Empty;
2023-04-01 15:33:39 +04:00
[Required]
public string Telephone { get; set; } = string.Empty;
//для реализации связи один ко многим со Счётом
[ForeignKey("CashierId")]
public virtual List<Account> Accounts { get; set; } = new();
//для реализации связи один ко многим с заявками на снятие наличных со счёта
[ForeignKey("CashierId")]
public virtual List<CashWithdrawal> CashWithdrawals { get; set; } = new();
2023-05-16 21:09:11 +04:00
//для реализации связи один ко многим с заявками на переводы денег
[ForeignKey("CashierId")]
public virtual List<MoneyTransfer> MoneyTransfers { get; set; } = new();
public static Cashier Create(BankYouBancruptDatabase context, CashierBindingModel model)
{
return new Cashier()
{
Id = model.Id,
Name = model.Name,
Surname = model.Surname,
Patronymic = model.Patronymic,
Email = model.Email,
Telephone = model.Telephone,
Password = model.Password
};
}
public void Update(CashierBindingModel model)
{
Id = model.Id;
Name = model.Name;
Surname = model.Surname;
Patronymic = model.Patronymic;
Email = model.Email;
Telephone = model.Telephone;
Password = model.Password;
}
public CashierViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Surname = Surname,
Patronymic = Patronymic,
Email = Email,
Telephone = Telephone,
Password = Password
};
}
2023-04-01 15:33:39 +04:00
}