я думаю надо доделать модель перевода денег, добавить id операции на пополнение, сделал бизнес логику, binding модели , кроме отчетов немного докинул в бд
This commit is contained in:
parent
7e7f0a5c24
commit
045c185766
23
Bank/BankContracts/BindingModels/DebitingBindingModel.cs
Normal file
23
Bank/BankContracts/BindingModels/DebitingBindingModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using BankDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class DebitingBindingModel : IDebitingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int CardId { get; set; }
|
||||
// и тут я понял почему ты задавался вопросом про id, надо подумать
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public double Sum { get; set; }
|
||||
|
||||
public DateTime DateDebit { get; set; } = DateTime.Now;
|
||||
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@ namespace BankContracts.BindingModels
|
||||
public class MoneyTransferBindingModel : IMoneyTransferModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int Sum { get; set; }
|
||||
//сменили int на double
|
||||
public double Sum { get; set; }
|
||||
|
||||
public int CashierId { get; set; }
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ICashWithdrawalLogic
|
||||
{
|
||||
List<CashWithdrawalViewModel>? ReadList(CashWithdrawalSearchModel? model);
|
||||
|
||||
CashWithdrawalViewModel? ReadElement(CashWithdrawalSearchModel model);
|
||||
|
||||
bool Create(CashWithdrawalBindingModel model, bool flag);
|
||||
|
||||
bool Update(CashWithdrawalBindingModel model);
|
||||
|
||||
bool Delete(CashWithdrawalBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ICreditingLogic
|
||||
{
|
||||
List<CreditingViewModel>? ReadList(CreditingSearchModel? model);
|
||||
|
||||
CreditingViewModel? ReadElement(CreditingSearchModel model);
|
||||
|
||||
bool Create(CreditingBindingModel model);
|
||||
|
||||
bool Update(CreditingBindingModel model);
|
||||
|
||||
bool Delete(CreditingBindingModel model);
|
||||
}
|
||||
}
|
22
Bank/BankContracts/BusinessLogicsContracts/IDebitingLogic.cs
Normal file
22
Bank/BankContracts/BusinessLogicsContracts/IDebitingLogic.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using BankContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IDebitingLogic
|
||||
{
|
||||
List<DebitingViewModel>? ReadList(DebitingSearchModel? model);
|
||||
|
||||
DebitingViewModel? ReadElement(DebitingSearchModel model);
|
||||
|
||||
bool Create(DebitingBindingModel model);
|
||||
|
||||
bool Update(DebitingBindingModel model);
|
||||
|
||||
bool Delete(DebitingBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IMoneyTransferLogic
|
||||
{
|
||||
List<MoneyTransferViewModel>? ReadList(MoneyTransferSearchModel? model);
|
||||
|
||||
MoneyTransferViewModel? ReadElement(MoneyTransferSearchModel model);
|
||||
|
||||
bool Create(MoneyTransferBindingModel model);
|
||||
|
||||
bool Update(MoneyTransferBindingModel model);
|
||||
|
||||
bool Delete(MoneyTransferBindingModel model);
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ namespace BankContracts.SearchModels
|
||||
public DateTime? DateWithdrawal { get; set; }
|
||||
|
||||
public int? DebitingId { get; set; } // выдача ведь связана со снятием???
|
||||
//выдача связана с заявкой на получение, вроде все верно, если что потом чекем
|
||||
|
||||
public int? ClientId { get; set; } // А надо добавлять клиента
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ namespace BankContracts.SearchModels
|
||||
|
||||
public DateTime? DateCrediting { get; set; }
|
||||
|
||||
public int? UserId { get; set; } // ИЛИ лучше CLientId
|
||||
public int? UserId { get; set; } // ИЛИ лучше CLientId, правильнее будет юзер
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace BankContracts.SearchModels
|
||||
|
||||
public int? CardId { get; set; }
|
||||
|
||||
public int? UserId { get; set; } // Возможно лишнюю фигню делаю и лучше ClientId
|
||||
public int? UserId { get; set; } // Возможно лишнюю фигню делаю и лучше ClientId , по нашей бд именно к пользователю относятся операции по пополнению
|
||||
|
||||
public int? Sum { get; set; }
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace BankContracts.SearchModels
|
||||
|
||||
public int? Crediting { get; set; }
|
||||
|
||||
public int? ClientId { get; set; } // ТОТ ЖЕ НАСУЩНЫЙ ВОПРОС, А НАДО?
|
||||
public int? ClientId { get; set; } // ТОТ ЖЕ НАСУЩНЫЙ ВОПРОС, А НАДО? тут у меня тоже вопрос , по идеи надо, потому что, как я понял можно перевод со счета на карту можно
|
||||
|
||||
// Навский случай типа два аккаунта, один отправитель, другой получатель
|
||||
public int? AccountSenderId { get; set; }
|
||||
|
29
Bank/BankContracts/ViewModels/MoneyTransferViewModel.cs
Normal file
29
Bank/BankContracts/ViewModels/MoneyTransferViewModel.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using BankDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class MoneyTransferViewModel : IMoneyTransferModel
|
||||
{
|
||||
//как будет выглядеть перевод
|
||||
//я понял, что надо модель доработать скорее всего, потому что мы же переводим не в пустоту , поэтому надо добавить кому и куда переводим
|
||||
//хотя если судить по нашей бд, которую принял у нас Эгов не должно быть отправителя и получателя , да еще и номеров счета
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Сумма перевода")]
|
||||
public double Sum { get; set; }
|
||||
|
||||
[DisplayName("Дата операции")]
|
||||
public DateTime DateTransfer { get; set; } = DateTime.Now;
|
||||
|
||||
public int CashierId { get; set; }
|
||||
|
||||
[DisplayName("Фамилия кассира")]
|
||||
public string CashierSurname { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -20,4 +20,8 @@
|
||||
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Implements\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
35
Bank/BankDatabaseImplement/Models/Account.cs
Normal file
35
Bank/BankDatabaseImplement/Models/Account.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using BankDataModels.Enums;
|
||||
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 Account : IAccountModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string AccountNumber { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public int CashierId { get; set; }
|
||||
[Required]
|
||||
public int ClientId { get; set; }
|
||||
//чтобы передать ФИО клиета
|
||||
public virtual Client Client { get; set; }
|
||||
[Required]
|
||||
public double Balance { get; set; }
|
||||
[Required]
|
||||
public DateTime DateOpen { get; set; }
|
||||
[Required]
|
||||
public StatusAccount StatusAccount { get; set; }
|
||||
//для реализации связи один ко многим со Снятием наличных
|
||||
[ForeignKey("AccountId")]
|
||||
public virtual List<CashWithdrawal> CashWithdrawals { get; set; } = new();
|
||||
}
|
||||
}
|
76
Bank/BankDatabaseImplement/Models/CashWithdrawal.cs
Normal file
76
Bank/BankDatabaseImplement/Models/CashWithdrawal.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.StoragesModels;
|
||||
using BankDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankDatabaseImplement.Models
|
||||
{
|
||||
public class CashWithdrawal : ICashWithdrawalModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int DebitingId { get; set; }
|
||||
|
||||
//для передачи номера заявки
|
||||
public virtual Debiting Debiting { get; set; }
|
||||
|
||||
[Required]
|
||||
public int AccountId { get; set; }
|
||||
|
||||
//для передачи названия изделия
|
||||
public virtual Account Account { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CashierId { get; set; }
|
||||
|
||||
//для передачи фамилии кассира
|
||||
public virtual Cashier Cashier { get; set; }
|
||||
|
||||
[Required]
|
||||
public double Sum { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime DateWithdrawal { get; set; }
|
||||
|
||||
public static CashWithdrawal Create(BankDatabase context, CashWithdrawalBindingModel model)
|
||||
{
|
||||
return new CashWithdrawal()
|
||||
{
|
||||
Id = model.Id,
|
||||
AccountId = model.AccountId,
|
||||
Account = context.Accounts.First(x => x.Id == model.AccountId),
|
||||
DebitingId = model.DebitingId,
|
||||
Debiting = context.Debitings.First(x => x.Id == model.DebitingId),
|
||||
CashierId = model.CashierId,
|
||||
Cashier = context.Cashiers.First(x => x.Id == model.CashierId),
|
||||
Sum = model.Sum,
|
||||
DateWithdrawal = model.DateWithdrawal
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(CashWithdrawalBindingModel model)
|
||||
{
|
||||
DateWithdrawal = model.DateWithdrawal;
|
||||
}
|
||||
|
||||
public CashWithdrawalViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
AccountId = AccountId,
|
||||
CashierId = CashierId,
|
||||
DebitingId = DebitingId,
|
||||
AccountNumber = Account.AccountNumber,
|
||||
SurmaneCashier = Cashier.Surname,
|
||||
DebbitingNumber = Debiting.Id,
|
||||
DebitingStatus = Debiting.Status,
|
||||
Sum = Sum,
|
||||
DateWithdrawal = DateWithdrawal
|
||||
};
|
||||
}
|
||||
}
|
84
Bank/BankDatabaseImplement/Models/Cashier.cs
Normal file
84
Bank/BankDatabaseImplement/Models/Cashier.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankDatabaseImplement.Models
|
||||
{
|
||||
public class Cashier : ICashierModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[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 MobilePhone { get; set; } = string.Empty;
|
||||
|
||||
//для реализации связи один ко многим со Счётом
|
||||
[ForeignKey("CashierId")]
|
||||
public virtual List<Account> Accounts { get; set; } = new();
|
||||
|
||||
//для реализации связи один ко многим с заявками на снятие наличных со счёта
|
||||
[ForeignKey("CashierId")]
|
||||
public virtual List<CashWithdrawal> CashWithdrawals { get; set; } = new();
|
||||
|
||||
//для реализации связи один ко многим с заявками на переводы денег
|
||||
[ForeignKey("CashierId")]
|
||||
public virtual List<MoneyTransfer> MoneyTransfers { get; set; } = new();
|
||||
|
||||
public static Cashier Create(BankDatabase context, CashierBindingModel model)
|
||||
{
|
||||
return new Cashier()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Surname = model.Surname,
|
||||
Patronymic = model.Patronymic,
|
||||
Email = model.Email,
|
||||
MobilePhone = model.MobilePhone,
|
||||
Password = model.Password
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(CashierBindingModel model)
|
||||
{
|
||||
Id = model.Id;
|
||||
Name = model.Name;
|
||||
Surname = model.Surname;
|
||||
Patronymic = model.Patronymic;
|
||||
Email = model.Email;
|
||||
MobilePhone = model.MobilePhone;
|
||||
Password = model.Password;
|
||||
}
|
||||
|
||||
public CashierViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Surname = Surname,
|
||||
Patronymic = Patronymic,
|
||||
Email = Email,
|
||||
MobilePhone = MobilePhone,
|
||||
Password = Password
|
||||
};
|
||||
}
|
||||
}
|
58
Bank/BankDatabaseImplement/Models/Debiting.cs
Normal file
58
Bank/BankDatabaseImplement/Models/Debiting.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using BankDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankDatabaseImplement.Models
|
||||
{
|
||||
public class Debiting : IDebitingModel
|
||||
{
|
||||
//реализация операции на пополнение
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CardId { get; set; }
|
||||
public virtual Card Card { get; set; }
|
||||
[Required]
|
||||
public int ClientId { get; set; }
|
||||
public virtual Client Client { get; set; }
|
||||
[Required]
|
||||
public double Sum { get; set; }
|
||||
[Required]
|
||||
public DateTime DateDebit { get; set; } = DateTime.Now;
|
||||
}
|
||||
|
||||
public DebitingViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CardId = CardId,
|
||||
CardNumber = Card.Number,
|
||||
ClientId = ClientId,
|
||||
Sum = Sum,
|
||||
DateDebit = DateDebit,
|
||||
};
|
||||
|
||||
public static Debiting Create(BankDatabase context, DebitingBindingModel model)
|
||||
{
|
||||
return new Debiting()
|
||||
{
|
||||
Id = model.Id,
|
||||
CardId = model.CardId,
|
||||
Card = context.Cards.First(x => x.Id == model.CardId),
|
||||
ClientId = model.ClientId,
|
||||
Sum = model.Sum,
|
||||
DateDebit = model.DateDebit,
|
||||
};
|
||||
}
|
||||
//вот тут хз, надо ли обновлять эту операцию, если судить чисто логически, то не надо ОБДУМАТЬ!!!!!!!!
|
||||
public void Update(DebitingBindingModel model)
|
||||
{
|
||||
DateClose = model.DateClose;
|
||||
|
||||
Status = model.Status;
|
||||
}
|
||||
}
|
||||
}
|
74
Bank/BankDatabaseImplement/Models/MoneyTransfer.cs
Normal file
74
Bank/BankDatabaseImplement/Models/MoneyTransfer.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankDatabaseImplement.Models
|
||||
{
|
||||
public class MoneyTransfer : IMoneyTransferModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public double Sum { get; set; }
|
||||
|
||||
public int? AccountSenderId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int AccountPayeeId { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime DateTransfer { get; set; }
|
||||
|
||||
public int? CreditingId { get; set; }
|
||||
|
||||
public int CashierId { get; set; }
|
||||
|
||||
public virtual Cashier Cashier { get; set; }
|
||||
|
||||
public virtual Account AccountSender { get; set; }
|
||||
|
||||
public virtual Account AccountPayeer { get; set; }
|
||||
|
||||
public static MoneyTransfer Create(BankDatabase context, MoneyTransferBindingModel model)
|
||||
{
|
||||
return new MoneyTransfer()
|
||||
{
|
||||
Id = model.Id,
|
||||
Sum = model.Sum,
|
||||
Cashier = context.Cashiers.First(x => x.Id == model.CashierId),
|
||||
AccountSender = model.AccountSenderId == null ? null : context.Accounts.First(x => x.Id == model.AccountSenderId),
|
||||
AccountPayeer = context.Accounts.First(x => x.Id == model.AccountPayeeId),
|
||||
AccountSenderId = model.AccountSenderId,
|
||||
AccountPayeeId = model.AccountPayeeId,
|
||||
DateTransfer = model.DateTransfer,
|
||||
CreditingId = model.CreditingId,
|
||||
CashierId = model.CashierId
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(MoneyTransferBindingModel model)
|
||||
{
|
||||
Id = model.Id;
|
||||
DateTransfer = model.DateTransfer;
|
||||
}
|
||||
|
||||
public MoneyTransferViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
AccountPayeeId = AccountPayeeId,
|
||||
AccountSenderId = AccountSenderId,
|
||||
AccountPayeeNumber = AccountPayeer.AccountNumber,
|
||||
AccountSenderNumber = AccountSenderId == null ? null : AccountSender.AccountNumber,
|
||||
DateTransfer = DateTransfer,
|
||||
Sum = Sum,
|
||||
CreditingId = CreditingId,
|
||||
CashierId = CashierId,
|
||||
CashierSurname = Cashier.Surname
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user