Stage 1: DataModel, Contracts(не до конца), Database(не до конца)

This commit is contained in:
nikbel2004@outlook.com 2024-04-26 12:58:51 +04:00
parent 800865a3a5
commit 7e7f0a5c24
25 changed files with 553 additions and 8 deletions

View File

@ -10,8 +10,4 @@
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" /> <ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="StoragesModels\" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,24 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BindingModels
{
public class CashWithdrawalBindingModel: ICashWithdrawalModel
{
public int Id { get; set; }
public int CashierId { get; set; }
public int DebitingId { get; set; }
public int AccountId { get; set; }
public double Sum { get; set; }
public DateTime DateWithdrawal { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BindingModels
{
public class CreditingBindingModel : ICreditingModel
{
public int Id { get; set; }
public double Sum { get; set; }
public DateTime DateCredit { get; set; }
public int ClientId { get; set; }
}
}

View File

@ -0,0 +1,28 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BindingModels
{
public class MoneyTransferBindingModel : IMoneyTransferModel
{
public int Id { get; set; }
public int Sum { get; set; }
public int CashierId { get; set; }
public DateTime DateTransfer { get; set; } = DateTime.Now;
public int? CreditingId { get; set; }
// для реализации между двумя клиента, аккаунтами
public int? AccountSenderId { get; set; }
public int AccountPayeeId { get; set; }
}
}

View File

@ -7,6 +7,7 @@ using System.Threading.Tasks;
namespace BankContracts.SearchModels namespace BankContracts.SearchModels
{ {
// Для поиска сущности "Счёт"
public class AccountSearchModel public class AccountSearchModel
{ {
public int Id { get; set; } public int Id { get; set; }

View File

@ -7,6 +7,7 @@ using System.Threading.Tasks;
namespace BankContracts.SearchModels namespace BankContracts.SearchModels
{ {
// Для поиска сущности "Банковская карта"
public class CardSearchModel public class CardSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
// Для поиска сущности "Выдача наличных"
public class CashWithdrawalSearchModel
{
public int? Id { get; set; }
public int? AccountId { get; set; }
public int? CashierId { get; set; }
public int? Sum { get; set; }
public DateTime? DateWithdrawal { get; set; }
public int? DebitingId { get; set; } // выдача ведь связана со снятием???
public int? ClientId { get; set; } // А надо добавлять клиента
}
}

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
namespace BankContracts.SearchModels namespace BankContracts.SearchModels
{ {
// Для поиска сущности "Кассир"
public class CashierSearchModel public class CashierSearchModel
{ {
public int Id { get; set; } public int Id { get; set; }

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
namespace BankContracts.SearchModels namespace BankContracts.SearchModels
{ {
// Для поиска сущности "Клиент"
public class ClientSearchModel public class ClientSearchModel
{ {
public int Id { get; set; } public int Id { get; set; }

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
// Для поиска сущности "Пополнение карты"
public class CreditingSearchModel
{
public int? Id { get; set; }
public int? CardId { get; set; }
public int? Sum { get; set; }
public DateTime? DateCrediting { get; set; }
public int? UserId { get; set; } // ИЛИ лучше CLientId
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
// Для поиска сущности "Получение наличных"
public class DebitingSearchModel
{
public int? Id { get; set; }
public int? CardId { get; set; }
public int? UserId { get; set; } // Возможно лишнюю фигню делаю и лучше ClientId
public int? Sum { get; set; }
public DateTime? DateDebit { get; set; }
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
// Для поиска сущности "Перевод денег"
public class MoneyTransferSearchModel
{
public int? Id { get; set; }
public int? Sum { get; set; }
public int? CashierId { get; set; }
public int? AccountId { get; set; }
public DateTime? DateTransfer { get; set; }
public int? Crediting { get; set; }
public int? ClientId { get; set; } // ТОТ ЖЕ НАСУЩНЫЙ ВОПРОС, А НАДО?
// Навский случай типа два аккаунта, один отправитель, другой получатель
public int? AccountSenderId { get; set; }
public int? AccountPayeeId { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesModels
{
// Интерфейс для хранилища счетов
public interface IAccountStorage
{
List<AccountViewModel> GetFullList();
List<AccountViewModel> GetFilteredList(AccountSearchModel model);
AccountViewModel? GetElement(AccountSearchModel model);
AccountViewModel? Insert(AccountBindingModel model);
AccountViewModel? Update(AccountBindingModel model);
AccountViewModel? Delete(AccountBindingModel model);
}
}

View File

@ -0,0 +1,27 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesModels
{
// Интерфейс для хранилища банковских карт
public interface ICardStorage
{
List<CardViewModel> GetFullList();
List<CardViewModel> GetFilteredList(CardSearchModel model);
CardViewModel? GetElement(CardSearchModel model);
CardViewModel? Insert(CardBindingModel model);
CardViewModel? Update(CardBindingModel model);
CardViewModel? Delete(CardBindingModel model);
}
}

View File

@ -0,0 +1,26 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesModels
{
// Интерфейс для хранилища выдачи наличных
public interface ICashWithdrawalStorage
{
List<CashWithdrawalViewModel> GetFullList();
List<CashWithdrawalViewModel> GetFilteredList(CashWithdrawalSearchModel model);
CashWithdrawalViewModel? GetElement(CashWithdrawalSearchModel model);
CashWithdrawalViewModel? Insert(CashWithdrawalBindingModel model);
CashWithdrawalViewModel? Update(CashWithdrawalBindingModel model);
CashWithdrawalViewModel? Delete(CashWithdrawalBindingModel model);
}
}

View File

@ -0,0 +1,27 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesModels
{
// Интерфейс для хранилища кассиров
public interface ICashierStorage
{
List<CashierViewModel> GetFullList();
List<CashierViewModel> GetFilteredList(CashierSearchModel model);
CashierViewModel? GetElement(CashierSearchModel model);
CashierViewModel? Insert(CashierBindingModel model);
CashierViewModel? Update(CashierBindingModel model);
CashierViewModel? Delete(CashierBindingModel model);
}
}

View File

@ -0,0 +1,27 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesModels
{
// Интерфейс для хранилища клиентов
public interface IClientStorage
{
List<ClientViewModel> GetFullList();
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
ClientViewModel? GetElement(ClientSearchModel model);
ClientViewModel? Insert(ClientBindingModel model);
ClientViewModel? Update(ClientBindingModel model);
ClientViewModel? Delete(ClientBindingModel model);
}
}

View File

@ -0,0 +1,25 @@
using BankContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesModels
{
// Интерфейс для хранилища пополнения карты
public interface ICreditingStorage
{
List<CreditingViewModel> GetFullList();
List<CreditingViewModel> GetFilteredList(CreditingSearchModel model);
CreditingViewModel? GetElement(CreditingSearchModel model);
CreditingViewModel? Insert(CreditingBindingModel model);
CreditingViewModel? Update(CreditingBindingModel model);
CreditingViewModel? Delete(CreditingBindingModel model);
}
}

View File

@ -0,0 +1,25 @@
using BankContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesModels
{
// Интерфейс для хранилища получения наличных
public interface IDebitingStorage
{
List<DebitingViewModel> GetFullList();
List<DebitingViewModel> GetFilteredList(DebitingSearchModel model);
DebitingViewModel? GetElement(DebitingSearchModel model);
DebitingViewModel? Insert(DebitingBindingModel model);
DebitingViewModel? Update(DebitingBindingModel model);
DebitingViewModel? Delete(DebitingBindingModel model);
}
}

View File

@ -0,0 +1,25 @@
using BankContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesModels
{
// Интерфейс для хранилища переводов денег
public interface IMoneyTransferStorage
{
List<MoneyTransferViewModel> GetFullList();
List<MoneyTransferViewModel> GetFilteredList(MoneyTransferSearchModel model);
MoneyTransferViewModel? GetElement(MoneyTransferSearchModel model);
MoneyTransferViewModel? Insert(MoneyTransferBindingModel model);
MoneyTransferViewModel? Update(MoneyTransferBindingModel model);
MoneyTransferViewModel? Delete(MoneyTransferBindingModel model);
}
}

View File

@ -14,5 +14,7 @@ namespace BankDataModels.Models
// Дата снятия денег // Дата снятия денег
DateTime DateDebit { get; } DateTime DateDebit { get; }
int ClientId { get; }
} }
} }

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace BankDataModels.Models namespace BankDataModels.Models
{ {
// Интерфейс, отвечающий за перевод денег // Интерфейс, отвечающий за перевод денег
public interface IMoneyTransfersModel : IId public interface IMoneyTransferModel : IId
{ {
// Сумма перевода // Сумма перевода
double Sum { get; } double Sum { get; }
@ -16,7 +16,5 @@ namespace BankDataModels.Models
DateTime DateTransfer { get; } DateTime DateTransfer { get; }
int CashierId { get; } int CashierId { get; }
int OperationReplenishment { get; }
} }
} }

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -15,4 +15,9 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,84 @@
using BankContracts.BindingModels;
using BankContracts.ViewModels;
using BankDataModels.Enums;
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Models
{
public class Card : ICardModel
{
public int Id { get; set; }
[Required]
public int ClientId { get; set; }
public virtual Client Client { get; set; }
[Required]
public int AccountId { get; set; }
public virtual Account Account { get; set; }
[Required]
public string Number { get; set; } = string.Empty;
[Required]
public double Balance { get; set; }
[Required]
public DateTime Period { get; set; } = DateTime.Now;
[Required]
public StatusCard StatusCard { get; set; } = StatusCard.Закрыта;
[Required]
public string? ClientSurname { get; set; }
//[ForeignKey("CardId")]
//public virtual List<Crediting> Creditings { get; set; } = new();
//[ForeignKey("CardId")]
//public virtual List<Debiting> Debitings { get; set; } = new();
public CardViewModel GetViewModel => new()
{
Id = Id,
AccountId = AccountId,
ClientId = ClientId,
Number = Number,
Balance = Balance,
Period = Period,
StatusCard = StatusCard,
ClientSurname = ClientSurname
};
public static Card Create(BankDatabase context, CardBindingModel model)
{
return new Card()
{
Id = model.Id,
AccountId = model.AccountId,
Account = context.Accounts.First(x => x.Id == model.AccountId),
ClientId = model.ClientId,
Client = context.Clients.First(x => x.Id == model.ClientId),
Number = model.Number,
Balance = model.Balance,
Period = model.Period,
StatusCard = model.StatusCard,
};
}
public void Update(CardBindingModel model)
{
Period = model.Period;
}
}
}

View File

@ -0,0 +1,74 @@
using BankContracts.BindingModels;
using BankContracts.ViewModels;
using BankDataModels.Models;
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
{
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;
}
}
}