Добавление Models в DatabaseImplements для кассира.

This commit is contained in:
Programmist73 2023-04-01 20:27:26 +04:00
parent de5194b463
commit 6e7c9c27f0
4 changed files with 190 additions and 31 deletions

View File

@ -1,6 +1,11 @@
using BankYouBankruptDataModels.Models;
using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -9,18 +14,66 @@ namespace BankYouBankruptDatabaseImplement.Models
{
public class Account : IAccountModel
{
public string AccountNumber => throw new NotImplementedException();
public int Id { get; set; }
public int CashierId => throw new NotImplementedException();
[Required]
public string AccountNumber { get; set; } = string.Empty;
public int ClientId => throw new NotImplementedException();
[Required]
public int CashierId { get; set; }
public string PasswordAccount => throw new NotImplementedException();
[Required]
public int ClientId { get; set; }
public double Balance => throw new NotImplementedException();
[Required]
public string PasswordAccount { get; set; } = string.Empty;
public DateTime DateOpen => throw new NotImplementedException();
[Required]
public double Balance { get; set; }
public int Id => throw new NotImplementedException();
}
[Required]
public DateTime DateOpen { get; set; } = DateTime.Now;
//для реализации связи один ко многим со Снятием наличных
[ForeignKey("AccountId")]
public virtual List<CashWithdrawal> CashWithdrawals { get; set; } = new();
//для реализации связи один ко многим с Переводом денег
[ForeignKey("AccountSenderId")]
public virtual List<MoneyTransfer> MoneyTransferSenders { get; set; } = new();
[ForeignKey("AccountPayeeId")]
public virtual List<MoneyTransfer> MoneyTransferPayees { get; set; } = new();
public static Account Create(BankYouBancruptDatabase context, AccountBindingModel model)
{
return new Account()
{
Id = model.Id,
ClientId = model.ClientId,
PasswordAccount = model.PasswordAccount,
Balance = model.Balance,
DateOpen = model.DateOpen,
CashierId = model.CashierId,
AccountNumber = model.AccountNumber
};
}
public void Update(AccountBindingModel model)
{
Balance = model.Balance;
PasswordAccount = model.PasswordAccount;
}
public AccountViewModel GetViewModel => new()
{
Id = Id,
CashierId = CashierId,
ClientId = ClientId,
AccountNumber = AccountNumber,
Balance = Balance,
PasswordAccount = PasswordAccount,
DateOpen = DateOpen
};
}
}

View File

@ -1,6 +1,10 @@
using BankYouBankruptDataModels.Models;
using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -9,12 +13,34 @@ namespace BankYouBankruptDatabaseImplement.Models
{
public class CashWithdrawal : ICashWithdrawalModel
{
public int AccountId => throw new NotImplementedException();
public int Id { get; set; }
public int Sum => throw new NotImplementedException();
[Required]
public int AccountId { get; set; }
public DateTime DateOperation => throw new NotImplementedException();
[Required]
public int Sum { get; set; }
public int Id => throw new NotImplementedException();
}
[Required]
public DateTime DateOperation { get; set; }
public static CashWithdrawal Create(BankYouBancruptDatabase context, CashWithdrawalBindingModel model)
{
return new CashWithdrawal()
{
Id = model.Id,
AccountId = model.AccountId,
Sum = model.Sum,
DateOperation = model.DateOperation
};
}
public CashWithdrawalViewModel GetViewModel => new()
{
Id = Id,
AccountId = AccountId,
Sum = Sum,
DateOperation = DateOperation
};
}
}

View File

@ -1,6 +1,11 @@
using BankYouBankruptDataModels.Models;
using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -9,18 +14,64 @@ namespace BankYouBankruptDatabaseImplement.Models
{
public class Cashier : ICashierModel
{
public string Password => throw new NotImplementedException();
public int Id { get; set; }
public string Name => throw new NotImplementedException();
[Required]
public string Password { get; set; } = string.Empty;
public string Surname => throw new NotImplementedException();
[Required]
public string Name { get; set; } = string.Empty;
public string Patronymic => throw new NotImplementedException();
[Required]
public string Surname { get; set; } = string.Empty;
public string Email => throw new NotImplementedException();
[Required]
public string Patronymic { get; set; } = string.Empty;
public string Telephone => throw new NotImplementedException();
[Required]
public string Email { get; set; } = string.Empty;
public int Id => throw new NotImplementedException();
}
[Required]
public string Telephone { get; set; } = string.Empty;
//для реализации связи один ко многим со Счётом
[ForeignKey("CashierId")]
public virtual List<Account> Accounts { 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
};
}
}

View File

@ -1,6 +1,10 @@
using BankYouBankruptDataModels.Models;
using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -9,14 +13,39 @@ namespace BankYouBankruptDatabaseImplement.Models
{
public class MoneyTransfer : IMoneyTransferModel
{
public int Sum => throw new NotImplementedException();
public int Id { get; set; }
public int AccountSenderId => throw new NotImplementedException();
[Required]
public int Sum { get; set; }
public int AccountPayeeId => throw new NotImplementedException();
[Required]
public int AccountSenderId { get; set; }
public DateTime DateOperation => throw new NotImplementedException();
[Required]
public int AccountPayeeId { get; set; }
public int Id => throw new NotImplementedException();
}
[Required]
public DateTime DateOperation { get; set; }
public static MoneyTransfer Create(BankYouBancruptDatabase context, MoneyTransferBindingModel model)
{
return new MoneyTransfer()
{
Id = model.Id,
Sum = model.Sum,
AccountSenderId = model.AccountSenderId,
AccountPayeeId = model.AccountPayeeId,
DateOperation = model.DateOperation
};
}
public MoneyTransferViewModel GetViewModel => new()
{
Id = Id,
AccountPayeeId = AccountPayeeId,
AccountSenderId = AccountSenderId,
DateOperation = DateOperation,
Sum = Sum
};
}
}