database improvements...
This commit is contained in:
parent
5c5960cd68
commit
690332d5b5
|
|
@ -0,0 +1,6 @@
|
|||
namespace TIAM.Core;
|
||||
|
||||
public enum ProductType : byte
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,14 +1,17 @@
|
|||
using AyCode.Database.Tests;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Database.DbContexts;
|
||||
|
||||
namespace TIAM.Database.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class DatabaseTest
|
||||
public class DatabaseTest : DatabaseTestModelBase
|
||||
{
|
||||
|
||||
[TestInitialize]
|
||||
public void Setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
|
|
|||
|
|
@ -32,9 +32,15 @@
|
|||
<Reference Include="AyCode.Core.Server">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Database\bin\Debug\net7.0\AyCode.Core.Server.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Core.Tests">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Database.Tests\bin\Debug\net7.0\AyCode.Core.Tests.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Database">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Database\bin\Debug\net7.0\AyCode.Database.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Database.Tests">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Database.Tests\bin\Debug\net7.0\AyCode.Database.Tests.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Entities">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Database\bin\Debug\net7.0\AyCode.Entities.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
using AyCode.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TIAM.Database.DbContexts;
|
||||
|
||||
namespace TIAM.Database.DataLayers;
|
||||
|
||||
public class TiamDalBase<TDbContext> : DalBase<TDbContext> where TDbContext : TiamDbContextBase
|
||||
{
|
||||
//public TiamDalBase() : base(new TransferDestinationDbContext("DeveloperDbConnection"))
|
||||
//{
|
||||
// Ctx.Database. }
|
||||
}
|
||||
|
|
@ -3,10 +3,16 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AyCode.Database;
|
||||
using Microsoft.Identity.Client;
|
||||
using TIAM.Database.DbContexts;
|
||||
using TIAM.Entities.TransferDestinations;
|
||||
|
||||
namespace TIAM.Database.DataLayers.TransferDestinations
|
||||
namespace TIAM.Database.DataLayers.TransferDestinations;
|
||||
|
||||
public class TransferDestinationDal : TiamDalBase<TransferDestinationDbContext>
|
||||
{
|
||||
internal class TransferDestinationDal
|
||||
public TransferDestinationDal() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TIAM.Database.DbContexts;
|
||||
|
||||
namespace TIAM.Database.DataLayers.Users
|
||||
{
|
||||
public class UserDal : TiamDalBase<UserDbContext>
|
||||
{
|
||||
public UserDal() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using AyCode.Database.DbContexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace TIAM.Database.DbContexts
|
||||
{
|
||||
|
|
@ -28,8 +29,9 @@ namespace TIAM.Database.DbContexts
|
|||
{
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
|
||||
//var connString = "Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Trusted_Connection=false;Encrypt=false;TrustServerCertificate=True;Connect Timeout=200;User ID=Anata_Development_Team;Password=v6f_?xNfg9N1;MultipleActiveResultSets=true";
|
||||
//optionsBuilder.UseSqlServer(connString);
|
||||
//optionsBuilder.UseSqlServer(Configuration.GetConnectionString("DeveloperDbConnection"));
|
||||
var connString = "Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Trusted_Connection=false;Encrypt=false;TrustServerCertificate=True;Connect Timeout=200;User ID=Anata_Development_Team;Password=v6f_?xNfg9N1;MultipleActiveResultSets=true";
|
||||
optionsBuilder.UseSqlServer(connString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AyCode.Database.DbContexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Entities.TransferDestinations;
|
||||
|
||||
namespace TIAM.Database.DbContexts
|
||||
{
|
||||
public class UserDbContext : TiamDbContextBase
|
||||
{
|
||||
public DbSet<TransferDestination> TransferDestinations { get; set; }
|
||||
|
||||
public UserDbContext() //: this(string.Empty)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public UserDbContext(string name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
public UserDbContext(DbContextOptions<DbContext> options, string name) : base(options, name)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Permissions;
|
||||
|
||||
[Table("PermissionContextMapping")]
|
||||
public class PermissionContextMapping : IEntityGuid, ITimeStampInfo
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
public Guid ContextId { get; set; }
|
||||
public Guid SubjectId { get; set; }
|
||||
|
||||
public short SubjectType { get; set; }
|
||||
public int Permissions { get; set; }
|
||||
public bool IsBuiltin { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Permissions;
|
||||
|
||||
[Table("PermissionGroups")]
|
||||
public class PermissionGroup : IEntityGuid, ITimeStampInfo
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
string GroupName { get; set; }
|
||||
bool IsBuiltin { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Permissions;
|
||||
|
||||
[Table("PermissionGroupUserMapping")]
|
||||
public class PermissionGroupUserMapping : IEntityGuid, ITimeStampInfo
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public Guid PermissionContextMappingId { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Permissions;
|
||||
|
||||
[Table("PermissionsTypes")]
|
||||
public class PermissionsType : IEntityGuid, ITimeStampInfo
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
public Guid ContextId { get; set; }
|
||||
|
||||
public string PermissionName { get; set; }
|
||||
public int PermissionBit { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
using TIAM.Core;
|
||||
|
||||
namespace TIAM.Entities.Products;
|
||||
|
||||
[Table("Product")]
|
||||
public class Product : IEntityGuid, ITimeStampInfo
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public ProductType ProductType { get; set; }
|
||||
public Guid UsermediaId { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public float Price { get; set; }
|
||||
public string JsonDetails { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Products;
|
||||
|
||||
[Table("ServiceProvider")]
|
||||
public class ServiceProvider : IEntityGuid, ITimeStampInfo
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
public Guid OwnerId { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -27,4 +27,12 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TIAM.Core\TIAM.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Users\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Users;
|
||||
|
||||
[Table("AssignedUser")]
|
||||
public class AssignedUser : IEntityGuid, ITimeStampInfo
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
public Guid ProductId { get; set; }
|
||||
public Guid EmployeeUserId { get; set; }
|
||||
|
||||
public int UserRoles { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
@inherits LayoutComponentBase
|
||||
@using TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMSharedUI.Pages
|
||||
@inject IUserDataService UserDataService;
|
||||
@inject IJSRuntime jsRuntime
|
||||
|
||||
|
|
@ -10,6 +11,8 @@
|
|||
|
||||
<main>
|
||||
|
||||
<ChooseDestionation>
|
||||
</ChooseDestionation>
|
||||
|
||||
<article class="content">
|
||||
@{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Reflection.Metadata;
|
||||
using TIAM.Database.DataLayers;
|
||||
using TIAM.Database.DataLayers.TransferDestinations;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
using TIAM.Database.DbContexts;
|
||||
using TIAM.Entities.TransferDestinations;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
|
|
@ -24,13 +27,13 @@ namespace TIAMWebApp.Server.Controllers
|
|||
|
||||
//};
|
||||
|
||||
private readonly TransferDestinationDbContext _transferDestinationDbContext;
|
||||
private readonly UserDal _userDal;
|
||||
private readonly ILogger<TransferDataAPIController> _logger;
|
||||
|
||||
public TransferDataAPIController(ILogger<TransferDataAPIController> logger, TransferDestinationDbContext transferDestinationDbContext)
|
||||
public TransferDataAPIController(ILogger<TransferDataAPIController> logger, UserDal userDal)
|
||||
{
|
||||
_logger = logger;
|
||||
_transferDestinationDbContext = transferDestinationDbContext;
|
||||
_userDal = userDal;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
|
@ -38,7 +41,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
{
|
||||
//return new JsonResult(await _transferDestinationDbContext.TransferDestinations.ToListAsync());
|
||||
|
||||
var result = await _transferDestinationDbContext.TransferDestinations.ToListAsync();
|
||||
var result = await _userDal.Ctx.TransferDestinations.ToListAsync();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using TIAM.Database.DataLayers;
|
||||
using TIAM.Entities.TransferDestinations;
|
||||
using TIAM.Database.DbContexts;
|
||||
using TIAM.Database.DataLayers.TransferDestinations;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
|
@ -13,7 +16,9 @@ var builder = WebApplication.CreateBuilder(args);
|
|||
|
||||
builder.Services.AddControllersWithViews();
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddDbContext<TransferDestinationDbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DeveloperDbConnection")));;
|
||||
//builder.Services.AddDbContext<TransferDestinationDbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DeveloperDbConnection")));
|
||||
//builder.Services.AddScoped<TiamDalBase<TransferDestinationDbContext>>(x => x.GetService<TransferDestinationDbContext>());
|
||||
builder.Services.AddScoped<UserDal>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
|
|
|||
|
|
@ -13,13 +13,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAMMobileApp", "TIAMMobile
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAMSharedUI", "TIAMSharedUI\TIAMSharedUI.csproj", "{3A24B495-45C4-4B38-B5C3-B1FD83490764}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TIAM.Database", "TIAM.Database\TIAM.Database.csproj", "{DABD68DB-9C9E-4A05-961F-3F1E4CAFB67C}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Database", "TIAM.Database\TIAM.Database.csproj", "{DABD68DB-9C9E-4A05-961F-3F1E4CAFB67C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TIAM.Database.Test", "TIAM.Database.Test\TIAM.Database.Test.csproj", "{E6DD4AC5-A797-4341-8B70-E2AF647E2AE2}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Database.Test", "TIAM.Database.Test\TIAM.Database.Test.csproj", "{E6DD4AC5-A797-4341-8B70-E2AF647E2AE2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TIAM.Entities", "TIAM.Entities\TIAM.Entities.csproj", "{1DAB894A-376F-4F94-BDF1-452F901941F7}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Entities", "TIAM.Entities\TIAM.Entities.csproj", "{1DAB894A-376F-4F94-BDF1-452F901941F7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TIAM.Entities.Server", "TIAM.Entities.Server\TIAM.Entities.Server.csproj", "{BDDF5F32-D275-4BBB-9C81-8DCB1025A935}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Entities.Server", "TIAM.Entities.Server\TIAM.Entities.Server.csproj", "{BDDF5F32-D275-4BBB-9C81-8DCB1025A935}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TIAM.Core", "TIAM.Core\TIAM.Core.csproj", "{4FDE0CD3-5914-4919-933B-6B0E04275313}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -65,6 +67,10 @@ Global
|
|||
{BDDF5F32-D275-4BBB-9C81-8DCB1025A935}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BDDF5F32-D275-4BBB-9C81-8DCB1025A935}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BDDF5F32-D275-4BBB-9C81-8DCB1025A935}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4FDE0CD3-5914-4919-933B-6B0E04275313}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4FDE0CD3-5914-4919-933B-6B0E04275313}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4FDE0CD3-5914-4919-933B-6B0E04275313}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4FDE0CD3-5914-4919-933B-6B0E04275313}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
Loading…
Reference in New Issue