Add EF objects
This commit is contained in:
parent
6c5a4bfb26
commit
b7996872cb
16 changed files with 167 additions and 8 deletions
|
@ -1,10 +1,10 @@
|
||||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
public class ApplicationDbContext : IdentityDbContext<IdentityUser>
|
namespace DrinkRateAPI.Contexts;
|
||||||
|
|
||||||
|
public class ApplicationDbContext : DbContext
|
||||||
{
|
{
|
||||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) :
|
public ApplicationDbContext(DbContextOptions<DbContext> options) :
|
||||||
base(options)
|
base(options)
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
12
DrinkRateAPI/Contexts/IdentityDbContext.cs
Normal file
12
DrinkRateAPI/Contexts/IdentityDbContext.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace DrinkRateAPI.Contexts;
|
||||||
|
|
||||||
|
public class IdentityDbContext : IdentityDbContext<IdentityUser>
|
||||||
|
{
|
||||||
|
public IdentityDbContext(DbContextOptions<IdentityDbContext> options) :
|
||||||
|
base(options)
|
||||||
|
{ }
|
||||||
|
}
|
14
DrinkRateAPI/DbEntities/DbCompany.cs
Normal file
14
DrinkRateAPI/DbEntities/DbCompany.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbCompany
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public Guid TableId { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbProduct> Products { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbCompanyRating> CompanyRatings { get; set; }
|
||||||
|
|
||||||
|
public string CompanyName { get; set; }
|
||||||
|
}
|
14
DrinkRateAPI/DbEntities/DbCompanyRating.cs
Normal file
14
DrinkRateAPI/DbEntities/DbCompanyRating.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbCompanyRating
|
||||||
|
{
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
public Guid CompanyId { get; set; }
|
||||||
|
|
||||||
|
public Guid CompanyTableId { get; set; }
|
||||||
|
|
||||||
|
public byte Rating { get; set; }
|
||||||
|
|
||||||
|
public string? Comment { get; set; }
|
||||||
|
}
|
10
DrinkRateAPI/DbEntities/DbCompanyTable.cs
Normal file
10
DrinkRateAPI/DbEntities/DbCompanyTable.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbCompanyTable
|
||||||
|
{
|
||||||
|
public string TableName { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbCompany> Companies { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbCompanyRating> CompanyRatings { get; set; }
|
||||||
|
}
|
12
DrinkRateAPI/DbEntities/DbCompanyTableView.cs
Normal file
12
DrinkRateAPI/DbEntities/DbCompanyTableView.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbCompanyTableView
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public Guid CompanyTableId { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbUser> Users { get; set; }
|
||||||
|
|
||||||
|
// to do: permission types
|
||||||
|
}
|
12
DrinkRateAPI/DbEntities/DbProduct.cs
Normal file
12
DrinkRateAPI/DbEntities/DbProduct.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbProduct
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public Guid CompanyId { get; set; }
|
||||||
|
|
||||||
|
public Guid TableId { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbProductRating> ProductRatings { get; set; }
|
||||||
|
}
|
14
DrinkRateAPI/DbEntities/DbProductRating.cs
Normal file
14
DrinkRateAPI/DbEntities/DbProductRating.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbProductRating
|
||||||
|
{
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
public Guid ProductId { get; set; }
|
||||||
|
|
||||||
|
public Guid ProductTableId { get; set; }
|
||||||
|
|
||||||
|
public byte Rating { get; set; }
|
||||||
|
|
||||||
|
public string? Comment { get; set; }
|
||||||
|
}
|
12
DrinkRateAPI/DbEntities/DbProductTable.cs
Normal file
12
DrinkRateAPI/DbEntities/DbProductTable.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbProductTable
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public string TableName { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbProduct> Products { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbProductRating> ProductRatings { get; set; }
|
||||||
|
}
|
13
DrinkRateAPI/DbEntities/DbProductTableView.cs
Normal file
13
DrinkRateAPI/DbEntities/DbProductTableView.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbProductTableView
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public Guid ProductTableId { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbUser> Users { get; set; }
|
||||||
|
|
||||||
|
// to do: permission types
|
||||||
|
|
||||||
|
}
|
17
DrinkRateAPI/DbEntities/DbUser.cs
Normal file
17
DrinkRateAPI/DbEntities/DbUser.cs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbUser
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbCompanyTableView> CompanyTableViews { get; set; }
|
||||||
|
public ICollection<DbProductTableView> ProductTableViews { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbCompanyRating> CompanyRatings { get; set; }
|
||||||
|
public ICollection<DbProductRating> ProductRatings { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DbUserCompanyTableStats> UserCompanyTableStats { get; set; }
|
||||||
|
public ICollection<DbUserProductTableStats> UserProductTableStats { get; set; }
|
||||||
|
|
||||||
|
public string UserName { get; set; }
|
||||||
|
}
|
14
DrinkRateAPI/DbEntities/DbUserCompanyTableStats.cs
Normal file
14
DrinkRateAPI/DbEntities/DbUserCompanyTableStats.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbUserCompanyTableStats
|
||||||
|
{
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
public Guid CompanyTabelId { get; set; }
|
||||||
|
|
||||||
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
public int MaxCount { get; set; }
|
||||||
|
|
||||||
|
public int Credits { get; set; }
|
||||||
|
}
|
14
DrinkRateAPI/DbEntities/DbUserProductTableStats.cs
Normal file
14
DrinkRateAPI/DbEntities/DbUserProductTableStats.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
namespace DrinkRateAPI.DbEntities;
|
||||||
|
|
||||||
|
public class DbUserProductTableStats
|
||||||
|
{
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
public Guid ProductTabelId { get; set; }
|
||||||
|
|
||||||
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
public int MaxCount { get; set; }
|
||||||
|
|
||||||
|
public int Credits { get; set; }
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
using DrinkRateAPI.Contexts;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
@ -11,7 +12,7 @@ builder.Services.AddControllers();
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddAuthorization();
|
builder.Services.AddAuthorization();
|
||||||
builder.Services.AddIdentityApiEndpoints<IdentityUser>()
|
builder.Services.AddIdentityApiEndpoints<IdentityUser>()
|
||||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
.AddEntityFrameworkStores<IdentityDbContext>();
|
||||||
|
|
||||||
builder.Services.AddSwaggerGen(c =>
|
builder.Services.AddSwaggerGen(c =>
|
||||||
{
|
{
|
||||||
|
@ -48,7 +49,7 @@ builder.Services.AddSwaggerGen(c =>
|
||||||
});
|
});
|
||||||
|
|
||||||
// to do: remove
|
// to do: remove
|
||||||
builder.Services.AddDbContext<ApplicationDbContext>(
|
builder.Services.AddDbContext<IdentityDbContext>(
|
||||||
options => options.UseInMemoryDatabase("AppDb"));
|
options => options.UseInMemoryDatabase("AppDb"));
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
|
@ -13,7 +13,7 @@ using System.Reflection;
|
||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("DrinkRateAPI")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("DrinkRateAPI")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6c5a4bfb26569a7e7265bb1c583a538c85c2e021")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("DrinkRateAPI")]
|
[assembly: System.Reflection.AssemblyProductAttribute("DrinkRateAPI")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("DrinkRateAPI")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("DrinkRateAPI")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
a800cf208542da2e16464ad5cac9564d078e4662a36df15e3e96ae4fd84319f7
|
b838a9c23df8ad83db19dac2d0874f8f00f1219871c8dec6180564b8a5404e88
|
||||||
|
|
Loading…
Reference in a new issue