BankSystem7 0.5.4
See the version list below for details.
dotnet add package BankSystem7 --version 0.5.4
NuGet\Install-Package BankSystem7 -Version 0.5.4
<PackageReference Include="BankSystem7" Version="0.5.4" />
paket add BankSystem7 --version 0.5.4
#r "nuget: BankSystem7, 0.5.4"
// Install BankSystem7 as a Cake Addin #addin nuget:?package=BankSystem7&version=0.5.4 // Install BankSystem7 as a Cake Tool #tool nuget:?package=BankSystem7&version=0.5.4
Bank system 7
This library provides opportunities for using likeness of bank system. You can handle not only users but also other models like banks, cards and etc.
Updates in version 0.5.4
- Fixed bug in BankAccountRepository that due to occures exceptions when referring to property
All
.
Documentation
Structure of project
- Folder AppContext is folder where contains context classes for interaction with database without business logic.
- Folder docs contains files for documentation.
- Folder Extensions contains extension classes for different types.
- Folder Models contains entity and configuration models for library.
- Folder Services contains 3 sub folders: Configuration, Interfaces and Repositories.
- Folder Configuration contains classes for configuration library.
- Folder Interfaces contains interfaces which describes structure of inherited classes.
- Folder Repositories is folder with all business logic of project. Only there simple developer has access.
How to interact with library?
The library provides ways to pass and use own models. For example, You can inherit Your class from base class User and pass it as type to an instance of BankSystemBuilder
and use own model.
Developer can interact with library with:
BankSystemBuilder
class.builder.Services.AddNationBankSystem<...>()
service in ASP.NET.
And by following next steps:
- Create field of the class
ConfigurationOptions
that handles settings of services. - Next initialize
BankSystemBuilder
class and pass to the constructor field ofConfigurationOptions
as parameter. - Create field of the interface
IServiceConfiguration
and assign to it value from methodBuild()
of classBankSystemBuilder
. - Interact with repositories throughout public properties of the created field of the interface
IServiceConfiguration
.
New feature for library is adding services to internal DI in ASP.Net application. For that You have to write something like this:
in Program.cs
builder.Services.AddNationBankSystem<User, Card, BankAccount, Bank, Credit>(o => { o.ConnectionConfiguration = new NpgsqlConnectionConfiguration() { EnsureCreated = false, EnsureDeleted = false, DatabaseName = "Test", DatabaseManagementSystemType = DatabaseManagementSystemType.PostgreSql, Host = "localhost", Port = "5432", }; o.Credentials = new NpgsqlCredentials() { Username = "postgres", Password = "secret" }; o.OperationOptions = new OperationServiceOptions() { DatabaseName = "Test", }; // here we add database context classes with class that inherit ModelConfiguration o.Contexts = new Dictionary<DbContext, ModelConfiguration?> { { new ApplicationContext(), new ModelConfigurationTest() }, { new NewApplicationContext(), new NewModelConfigurationTest() }, }; }); //or builder.Services.AddNationBankSystem<User, Card, BankAccount, Bank, Credit>(new ConfigurationOptions() { ConnectionConfiguration = new NpgsqlConnectionConfiguration() { EnsureCreated = false, EnsureDeleted = false, DatabaseName = "Test", DatabaseManagementSystemType = DatabaseManagementSystemType.PostgreSql, Host = "localhost", Port = "5432", }, Credentials = new NpgsqlCredentials() { Username = "postgres", Password = "secret" }, OperationOptions = new OperationServiceOptions() { DatabaseName = "Test", }, // here we add database context classes with class that inherit ModelConfiguration Contexts = new Dictionary<DbContext, ModelConfiguration?> { { new ApplicationContext(), new ModelConfigurationTest() }, { new NewApplicationContext(), new NewModelConfigurationTest() }, }; });
But use only one of the above approaches to use service. Now You can don't specify LoggerOptions because by default logger is disabled.
in Your controller
private readonly IServiceConfiguration<User, Card, BankAccount, Bank, Credit> _service; public UsersController(IServiceConfiguration<User, Card, BankAccount, Bank, Credit> service) { _service = service; }
And all will work fine.
API documentation
AppContext
There are 3 classes context:
- GenericDbContext - main db context class that handles all needed operations.
- ApplicationContext - configures GenericDbContext to context class for this library.
- BankContext - is responsible for handling operations when use ApplicationContext is impossible.
API GenericDbContext
Methods:
private void DatabaseHandle()
- implements handling creating and deleting database.private void SetDatabaseManagementSystemType(DbContextOptionsBuilder optionsBuilder, DatabaseManagementSystemType dbmsType)
- method sets the database management system type for the given DbContextOptionsBuilder object.public void UpdateTracker<T>(T item, EntityState state, Action? action, DbContext context)
- updates states of entity. You should use this method with methodAvoidChanges(object[]? entities, DbContext context)
for the best state tracking of entities.public void UpdateTrackerRange(object[] items, EntityState state, Action? action, DbContext context)
- method updates states of entities. You should use this method with methodAvoidChanges(object[]? entities, DbContext context)
for the best state tracking of entitiespublic void AvoidChanges(object[]? entities, DbContext context)
- ensures that passed entities won't be changed during call methodSaveChanges()
.
API ApplicationContext
Methods:
internal ExceptionModel AvoidDuplication(Bank item)
- implements function for avoiding duplication in table Banks in the database.
Properties:
protected internal DbSet<User> Users { get; set; }
- an instance of the tableUsers
in database.protected internal DbSet<Bank> Banks { get; set; }
-an instance of the tableBanks
in database.protected internal DbSet<BankAccount> BankAccounts { get; set; }
- an instance of the tableBankAccounts
in database.protected internal DbSet<Credit> Credits { get; set; }
- an instance of the tableCredits
in database.
API BankContext
Methods:
public ExceptionModel CreateOperation(Operation operation, OperationKind operationKind)
- creates transaction operation.public async Task<ExceptionModel> CreateOperationAsync(Operation? operation, OperationKind operationKind)
- creates transaction operation asynchronously.public ExceptionModel DeleteOperation(Operation operation)
- deletes transaction operationpublic async Task<ExceptionModel> DeleteOperationAsync(Operation? operation)
- deletes transaction operation asynchronously.public ExceptionModel BankAccountWithdraw(User user, Bank bank, Operation operation)
- withdraws money from user bank account and accrual to bank's account.internal async Task<ExceptionModel> BankAccountWithdrawAsync(User? user, Bank? bank, Operation operation)
- withdraws money from user bank account and accrual to bank's account asynchronously.private ExceptionModel BankAccountAccrual(User user, Bank bank, Operation operation)
- accruals money to user bank account from bank's account.internal async Task<ExceptionModel> BankAccountAccrualAsync(User? user, Bank? bank, Operation operation)
- accruals money to user bank account from bank's account asynchronously.private StatusOperationCode GetStatusOperation(Operation operation, OperationKind operationKind)
- returns status of operation for next handling of operation.
Properties:
public DbSet<User> Users { get; set; }
- an instance of the tableUsers
in database.public DbSet<Bank> Banks { get; set; }
-an instance of the tableBanks
in database.public DbSet<Cards> Cards { get; set; }
- an instance of the tableCards
in database.public DbSet<BankAccount> BankAccounts { get; set; }
- an instance of the tableBankAccounts
in database.
Services
Services are dividing on 3 sub-folders:
- Configuration
- Interfaces
- Repositories
And some classes that don't belong to any of folders:
BankServiceOptions
- defines options that used by internal services.Logger
- service for logging some info about repositories operations.OperationService
- provides connection to mongodb services.
Configuration
Here located services for configuring library.
ConfigurationOptions
- service provides options for the most full configuring of library.ModelConfiguration
- service ensures correct relationships between models.ServiceConifiguration
- service that handles all services that there are in the library.
Interfaces (and abstract classes)
Here located interfaces which describes behavior of inherited repo-classes.
Interface
IRepository<T> : IReaderService<T>, IWriterService<T>, IDisposable where T : class
- interface for implement standard library logic.IQueryable<T> All { get; }
- implements getting a sequence of the objects from database.
Interface
IRepositoryAsync<T> : IReaderServiceAsync<T>, IWriterServiceAsync<T> where T : class
- interface for implement standard library logic asynchronously.IQueryable<T> All { get; }
- implements getting a sequence of the objects from database.
Interface
IReaderServiceAsync<T> where T : class
- interface for implement reading data from database asynchronously.Methods
Task<T> GetAsync(Expression<Func<T, bool>> predicate);
- implements getting an object from database with predicate asynchronously.Task<bool> ExistAsync(Expression<Func<T, bool>> predicate);
- implements checking exist object with in database predicate asynchronously.Task<bool> FitsConditionsAsync(T? item);
- implements logic for checking on conditions true of passed entity asynchronously.
Interface
IWriterServiceAsync<in T> where T : class
- interface for implement writing, updating and deleting data in databaseMethods
Task<ExceptionModel> CreateAsync(T item);
- implements adding entity in database asynchronously.Task<ExceptionModel> UpdateAsync(T item);
- implements updating entity in database asynchronously.Task<ExceptionModel> DeleteAsync(T item);
- implements deleting entity from database asynchronously.
Interface
IReaderService<T> where T : class
- interface for implement reading data from database.Methods
T Get(Expression<Func<T, bool>> predicate);
- implements getting an object from database with predicate.bool Exist(Expression<Func<T, bool>> predicate);
- implements checking exist object with in database predicate.bool FitsConditions(T? item);
- implements logic for checking on conditions true of passed entity.
Interface
IReaderServiceWithTracking<T> where T : class
- interface for implement reading data from database with another type of parameters.Methods
T GetWithTracking(Expression<Expression<Func<T, bool>>> predicate);
- implements getting an object from database with predicate.bool ExistWithTracking(Expression<Expression<Func<T, bool>>> predicate);
- implements checking exist object with in database predicate. PropertiesIQueryable<T> AllWithTracking { get; }
- implements getting a sequence of the objects from database.
Interface
IWriterService<in T> where T : class
- interface for implement writing, updating and deleting data in databaseMethods
ExceptionModel Create(T item);
- implements adding entity in database.ExceptionModel Update(T item);
- implements updating entity in database.ExceptionModel Delete(T item);
- implements deleting entity from database.
Interface
ILogger
- interface that provides standard set for loggingMethods
ExceptionModel Log(Report report);
- implements logging report in database.ExceptionModel Log(IEnumerable<Report> reports);
- implements logging collection of reports in database.
Properties
public bool IsReused { get; set; }
- defines possibility use already initialized logger.public LoggerOptions LoggerOptions { get; set; }
- defines options for logger configuration.
Abstract class
LoggerExecutor<TOperationType> where TOperationType : Enum
- simple implementation of service for added reports to logger queueMethods
virtual void Log(ExceptionModel exceptionModel, string methodName, string className, TOperationType operationType, ICollection<GeneralReport<TOperationType>> reports)
- implements standard logic of inserting log data to logger queue. Can be overrided.
Repositories
Repositories are implementation of various interfaces and working with context classes for interact with database.
BankRepository
- implements interfaceIRepository<T>
for handling bank model, contains methods for accrual or withdraw money from bank account and bank.BankAccountRepository
- implements interfaceIRepository<T>
for handling bank account model and Transfer money method.CardRepository
- implements interfaceIRepository<T>
for handling card model and Transfer money method.UserRepository
- implements interfaceIRepository<T>
for handling user model.CreditRepository
- implements interfaceIRepository<T>
for handling credit model and operations with credit(loan). For example: take, pay credit.LoggerRepository
- implements interfaceIRepository<T>
for handling reports.OperationRepository
- implements interfaceIRepository<T>
for handling operations.
When cause exception or error?
There are a lot of points when you can catch an exception or error while using api of project but we describe some of them:
- You use default connection string instead of Your. Can happen so that on Your machine won't database with name which was specified in default connection string.
- You change content of repositories or context class. If You change some of these You can get an error. Example:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.EnableSensitiveDataLogging();
optionsBuilder.UseSqlServer(queryConnection);
}
You'll write something like this
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.EnableSensitiveDataLogging();
optionsBuilder.UseSqlServer();
}
- You use methods incorrectly.
Example:
You want to delete operation therefore You have to use method
DeleteOperation(...)
but You use methodCreateOperation(...)
and of course You'll get an exception because methodCreateOperation(...)
has return typeExceptionModel
and it'll returnsExceptionModel.OperationFailed
because the same operation already exist in the database which You are using.
Remember!
Always change connection string either directly in context class, repository classes or use class BankServiceOptions for configuration. In any situations when Your program, OS or something else was broken, only You is responsible for it. Please, be more intelligent. :>
Conclusion
Downloading and next using this package is your responsible and only You decide use it or not. All exceptions and crashes of your projects is responsible on You. We was tested our product in many tests and have a conclusion in which says that all methods and logic of project are working correctly. So, we wish You luck.
Sincerely, hayako. Your program, OS or something else was broken, only You is responsible for it. Please, be more intelligent. :>
Conclusion
Downloading and next using this package is your responsible and only You decide use it or not. All exceptions and crashes of your projects is responsible on You. We was tested our product in many tests and have a conclusion in which says that all methods and logic of project are working correctly. So, we wish You luck.
Sincerely, hayako.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.AspNetCore.Cryptography.KeyDerivation (>= 8.0.0-preview.2.23153.2)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.EntityFrameworkCore (>= 8.0.0-preview.2.23128.3)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.0-preview.2.23128.3)
- MongoDB.Driver (>= 2.19.1)
- MySql.EntityFrameworkCore (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Npgsql (>= 8.0.0-preview.2)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.0-preview.2)
- NUnit (>= 3.13.3)
- System.Data.HashFunction.Interfaces (>= 2.0.0)
- System.Data.HashFunction.Jenkins (>= 2.0.0)
-
net7.0
- Microsoft.AspNetCore.Cryptography.KeyDerivation (>= 8.0.0-preview.2.23153.2)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.EntityFrameworkCore (>= 8.0.0-preview.2.23128.3)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.0-preview.2.23128.3)
- MongoDB.Driver (>= 2.19.1)
- MySql.EntityFrameworkCore (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Npgsql (>= 8.0.0-preview.2)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.0-preview.2)
- NUnit (>= 3.13.3)
- System.Data.HashFunction.Interfaces (>= 2.0.0)
- System.Data.HashFunction.Jenkins (>= 2.0.0)
-
net8.0
- Microsoft.AspNetCore.Cryptography.KeyDerivation (>= 8.0.0-preview.2.23153.2)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.EntityFrameworkCore (>= 8.0.0-preview.2.23128.3)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.0-preview.2.23128.3)
- MongoDB.Driver (>= 2.19.1)
- MySql.EntityFrameworkCore (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Npgsql (>= 8.0.0-preview.2)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.0-preview.2)
- NUnit (>= 3.13.3)
- System.Data.HashFunction.Interfaces (>= 2.0.0)
- System.Data.HashFunction.Jenkins (>= 2.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on BankSystem7:
Package | Downloads |
---|---|
Standart7
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
0.5.8 | 147 | 9/13/2023 | |
0.5.7 | 104 | 9/11/2023 | |
0.5.6 | 142 | 7/22/2023 | |
0.5.5 | 108 | 7/1/2023 | |
0.5.4 | 99 | 6/19/2023 | |
0.5.3 | 106 | 6/19/2023 | |
0.5.2 | 103 | 6/3/2023 | |
0.5.1 | 95 | 5/22/2023 | |
0.5.0 | 100 | 5/21/2023 | |
0.4.9 | 97 | 5/14/2023 | |
0.4.8 | 92 | 5/6/2023 | |
0.4.7 | 88 | 5/6/2023 | |
0.4.6 | 91 | 5/6/2023 | |
0.4.5 | 101 | 5/6/2023 | |
0.4.4 | 106 | 5/2/2023 | |
0.4.2 | 102 | 4/29/2023 | |
0.4.1 | 100 | 4/27/2023 | |
0.4.0 | 106 | 4/27/2023 | |
0.3.9 | 107 | 4/25/2023 | |
0.3.8 | 106 | 4/19/2023 | |
0.3.7 | 100 | 4/19/2023 | |
0.3.6-beta | 96 | 4/13/2023 | |
0.3.5-beta | 89 | 4/12/2023 | |
0.3.4-beta | 88 | 4/10/2023 | |
0.3.3-beta | 88 | 4/3/2023 | |
0.3.2-beta | 94 | 4/3/2023 | |
0.3.1-beta | 93 | 4/2/2023 | |
0.3.0-beta | 97 | 4/1/2023 | |
0.2.9-beta | 102 | 4/1/2023 | |
0.2.7-beta | 113 | 3/28/2023 | |
0.2.6-beta | 118 | 3/24/2023 | |
0.2.5-beta | 119 | 3/20/2023 | |
0.2.4-beta | 115 | 3/20/2023 | |
0.2.3-beta | 109 | 3/20/2023 | |
0.2.2-beta | 122 | 3/20/2023 | |
0.2.1-beta | 124 | 3/20/2023 | |
0.1.3-beta | 117 | 3/20/2023 | |
0.1.2-beta | 119 | 3/19/2023 | |
0.1.0-beta | 116 | 3/19/2023 |
Check README file before update to newer version.