2022-08-18 22:59:13 +03:00
|
|
|
using BlueWest.Data;
|
2022-08-22 00:14:50 +03:00
|
|
|
using BlueWest.WebApi.EF.Model;
|
2022-08-18 22:59:13 +03:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
2022-08-22 00:14:50 +03:00
|
|
|
namespace BlueWest.WebApi.EF
|
2022-08-18 22:59:13 +03:00
|
|
|
{
|
2022-08-19 02:02:57 +03:00
|
|
|
/// <summary>
|
|
|
|
/// Finance operations table
|
|
|
|
/// </summary>
|
2022-08-22 02:51:45 +03:00
|
|
|
public sealed class FinanceDbContext : DbContext
|
2022-08-18 22:59:13 +03:00
|
|
|
{
|
2022-09-08 06:15:44 +03:00
|
|
|
#region Transactions
|
|
|
|
|
2022-08-22 02:51:45 +03:00
|
|
|
/// <summary>
|
|
|
|
/// Table storing transactions
|
|
|
|
/// </summary>
|
|
|
|
public DbSet<FinanceOp> Transactions { get; set; }
|
2022-09-08 06:15:44 +03:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region TransactionType
|
|
|
|
|
2022-08-22 02:51:45 +03:00
|
|
|
/// <summary>
|
|
|
|
/// Table storing transaction types.
|
|
|
|
/// </summary>
|
|
|
|
public DbSet<FinanceOpType> TransactionTypes { get; set; }
|
2022-09-08 06:15:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Initialization
|
2022-08-19 06:18:50 +03:00
|
|
|
|
|
|
|
/// <summary>
|
2022-08-22 05:13:53 +03:00
|
|
|
/// CompanyDbContext constructor.
|
2022-08-19 06:18:50 +03:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="options"></param>
|
2022-08-22 02:51:45 +03:00
|
|
|
public FinanceDbContext(DbContextOptions<FinanceDbContext> options) : base(options)
|
2022-08-19 02:02:57 +03:00
|
|
|
{
|
|
|
|
Database.EnsureCreated();
|
|
|
|
}
|
2022-08-22 02:51:45 +03:00
|
|
|
|
|
|
|
/// <summary>
|
2022-08-22 05:13:53 +03:00
|
|
|
/// On model creating.
|
2022-08-22 02:51:45 +03:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="modelBuilder">Builder model of the database</param>
|
2022-08-19 06:18:50 +03:00
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
{
|
|
|
|
base.OnModelCreating(modelBuilder);
|
2022-08-20 05:47:32 +03:00
|
|
|
modelBuilder.ConfigureCurrentDbModel();
|
2022-08-19 06:18:50 +03:00
|
|
|
}
|
2022-09-08 06:15:44 +03:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2022-08-18 22:59:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|