Добавил интерфейс бизнес-логики, SearchModel, и Vie-шки, немного с бд поработал

This commit is contained in:
nikbel2004@outlook.com 2024-04-19 12:27:20 +04:00
parent abb4a21c4a
commit 800865a3a5
16 changed files with 374 additions and 10 deletions

View File

@ -11,10 +11,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="ViewModels\" />
<Folder Include="SearchModels\" />
<Folder Include="StoragesModels\" />
<Folder Include="BusinessLogicsContracts\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,26 @@
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.BusinessLogicsContracts
{
public interface IAccountLogic
{
List<AccountViewModel>? ReadList(AccountSearchModel? model);
AccountViewModel? ReadElement(AccountSearchModel model);
bool ChangeBalance(AccountSearchModel? model, int sum);
bool Create(AccountBindingModel model);
bool Update(AccountBindingModel model);
bool Delete(AccountBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
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.BusinessLogicsContracts
{
public interface ICardLogic
{
List<CardViewModel>? ReadList(CardSearchModel? model);
CardViewModel? ReadElement(CardSearchModel model);
bool Create(CardBindingModel model);
bool Update(CardBindingModel model);
bool Delete(CardBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
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.BusinessLogicsContracts
{
public interface ICashierLogic
{
List<CashierViewModel>? ReadList(CashierSearchModel? model);
CashierViewModel? ReadElement(CashierSearchModel model);
bool Create(CashierBindingModel model);
bool Update(CashierBindingModel model);
bool Delete(CashierBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
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.BusinessLogicsContracts
{
public interface IClientLogic
{
List<ClientViewModel>? ReadList(ClientSearchModel? model);
ClientViewModel? ReadElement(ClientSearchModel model);
bool Create(ClientBindingModel model);
bool Update(ClientBindingModel model);
bool Delete(ClientBindingModel model);
}
}

View File

@ -0,0 +1,26 @@
using BankDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
public class AccountSearchModel
{
public int Id { get; set; }
public int CashierId { get; set; }
public int ClientId { get; set; }
public string AccountNumber { get; set; } = string.Empty;
public double Balance { get; set; }
public DateTime DateOpen { get; set; }
public StatusAccount StatusAccount { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using BankDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
public class CardSearchModel
{
public int? Id { get; set; }
public int? ClientID { get; set; }
public int? AccountId { get; set; }
// Номер банковской карты
public string? Number { get; set; }
public double Balance { get; set; }
public DateTime Period { get; set; }
public StatusCard StatusCard { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
public class CashierSearchModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string Patronymic { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string MobilePhone { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
public class ClientSearchModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string Patronymic { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string MobilePhone { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,41 @@
using BankDataModels.Enums;
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 AccountViewModel : IAccountModel
{
public int Id { get; set; }
public int CashierId { get; set; }
public int ClientId { get; set; }
[DisplayName("Номер счёта")]
public string AccountNumber { get; set; } = string.Empty;
[DisplayName("Баланс")]
public double Balance { get; set; }
[DisplayName("Дата открытия")]
public DateTime DateOpen { get; set; } = DateTime.Now; // ИЛИ ТУТ СРОК ДЕЙСТВИЯ СЧЁТА???
[DisplayName("Статус счёта")]
public StatusAccount StatusAccount { get; set; } = StatusAccount.Закрыт;
// ВОЗМОЖНО ПОНАДОБИТЬСЯ ДЛЯ ОТЧЁТОВ
//[DisplayName("Имя")]
//public string Name { get; set; } = string.Empty;
//[DisplayName("Отчество")]
//public string Patronymic { get; set; } = string.Empty;
//public string PasswordAccount { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,36 @@
using BankDataModels.Enums;
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 CardViewModel : ICardModel
{
public int Id { get; set; }
public int ClientId { get; set; }
public int AccountId { get; set; }
// Номер банковской карты
[DisplayName("Номер карты")]
public string Number { get; set; } = string.Empty;
[DisplayName("Баланс карты")]
public double Balance { get; set; }
[DisplayName("Срок действия")]
public DateTime Period { get; set; } = DateTime.Now;
[DisplayName("Статус карты")]
public StatusCard StatusCard { get; set; } = StatusCard.Закрыта;
[DisplayName("Фамилия клиента")]
public string? ClientSurname { get; set; }
}
}

View File

@ -0,0 +1,33 @@
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 CashierViewModel : ICashierModel
{
public int Id { get; set; }
[DisplayName("Имя")]
public string Name { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string Surname { get; set; } = string.Empty;
[DisplayName("Отчество")]
public string Patronymic { get; set; } = string.Empty;
[DisplayName("Почта")]
public string Email { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
[DisplayName("Телефон")]
public string MobilePhone { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,33 @@
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 ClientViewModel : IClientModel
{
public int Id { get; set; }
[DisplayName("Имя")]
public string Name { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string Surname { get; set; } = string.Empty;
[DisplayName("Отчество")]
public string Patronymic { get; set; } = string.Empty;
[DisplayName("Почта")]
public string Email { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
[DisplayName("Телефон")]
public string MobilePhone { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement
{
public class BankDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source= \SQLEXPRESS;Initial Catalog=BankDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
}
}

View File

@ -6,4 +6,13 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.18" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.18" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.18">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -1,7 +0,0 @@
namespace BankDatabaseImplement
{
public class Class1
{
}
}