Add ISerialiyationToJson interface; Implement Transfer to UserProduct mapping, BuilderConfiguration; Add tests; EmailMessage in progress; refactoring, improvements, fixes, etc...
This commit is contained in:
parent
ca17d28bfa
commit
abe89543a7
|
|
@ -0,0 +1,7 @@
|
||||||
|
using AyCode.Core.Interfaces;
|
||||||
|
|
||||||
|
namespace TIAM.Core.Interfaces;
|
||||||
|
|
||||||
|
public interface ISerializableToJson : IAcSerializableToJson
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using AyCode.Core.Interfaces;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using TIAM.Core.Interfaces;
|
||||||
|
|
||||||
|
namespace TIAM.Core;
|
||||||
|
|
||||||
|
public static class SerializeObjectToJsonExtensions
|
||||||
|
{
|
||||||
|
private static string SerializeObjectToJson<T>(T source)
|
||||||
|
{
|
||||||
|
JsonSerializerSettings options = new()
|
||||||
|
{
|
||||||
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonConvert.SerializeObject(source, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ToJson<T>(this T source) where T : class, IAcSerializableToJson => SerializeObjectToJson(source);
|
||||||
|
public static string ToJson<T>(this IQueryable<T> source) where T : class, IAcSerializableToJson => SerializeObjectToJson(source);
|
||||||
|
public static string ToJson<T>(this IEnumerable<T> source) where T : class, IAcSerializableToJson => SerializeObjectToJson(source);
|
||||||
|
}
|
||||||
|
|
@ -6,4 +6,18 @@
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Interfaces\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="AyCode.Core">
|
||||||
|
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,14 @@
|
||||||
using AyCode.Database.Tests;
|
using AyCode.Database.Tests;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AyCode.Database.DataLayers.Users;
|
|
||||||
using AyCode.Utils.Extensions;
|
using AyCode.Utils.Extensions;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using TIAM.Core;
|
||||||
using TIAM.Core.Enums;
|
using TIAM.Core.Enums;
|
||||||
using TIAM.Database.DataLayers.Admins;
|
using TIAM.Database.DataLayers.Admins;
|
||||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
|
||||||
using TIAM.Database.DataLayers.Users;
|
|
||||||
using TIAM.Database.DbContexts.Admins;
|
using TIAM.Database.DbContexts.Admins;
|
||||||
using TIAM.Database.DbContexts.ServiceProviders;
|
|
||||||
using TIAM.Database.DbSets.Permissions;
|
|
||||||
using TIAM.Database.DbSets.Transfers;
|
|
||||||
using TIAM.Entities.Drivers;
|
using TIAM.Entities.Drivers;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
using TIAM.Models.Dtos.Users;
|
using TIAM.Models.Dtos.Users;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
using TIAM.Entities.Transfers;
|
using TIAM.Entities.Transfers;
|
||||||
|
|
||||||
namespace TIAM.Database.Test
|
namespace TIAM.Database.Test
|
||||||
|
|
@ -44,7 +33,7 @@ namespace TIAM.Database.Test
|
||||||
var permMapping = Dal.GetPermissionContextsViewBySubjectId(subjectId).ToList();
|
var permMapping = Dal.GetPermissionContextsViewBySubjectId(subjectId).ToList();
|
||||||
|
|
||||||
Assert.IsNotNull(permMapping, "PermissionContextsView is null");
|
Assert.IsNotNull(permMapping, "PermissionContextsView is null");
|
||||||
Assert.IsTrue(permMapping.Count > 0, "PermissionContextsView count: 0");
|
Assert.IsTrue(permMapping.Count != 0, "PermissionContextsView count: 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
|
|
@ -55,7 +44,7 @@ namespace TIAM.Database.Test
|
||||||
var permMapping = Dal.GetPermissionContextsViewByContextId(contextId).ToList();
|
var permMapping = Dal.GetPermissionContextsViewByContextId(contextId).ToList();
|
||||||
|
|
||||||
Assert.IsNotNull(permMapping, "PermissionContextsView is null");
|
Assert.IsNotNull(permMapping, "PermissionContextsView is null");
|
||||||
Assert.IsTrue(permMapping.Count > 0, "PermissionContextsView count: 0");
|
Assert.IsTrue(permMapping.Count != 0, "PermissionContextsView count: 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
|
|
@ -66,7 +55,7 @@ namespace TIAM.Database.Test
|
||||||
var permMapping = await Dal.GetPermissionContextsViewByContextIdAsync(contextId);
|
var permMapping = await Dal.GetPermissionContextsViewByContextIdAsync(contextId);
|
||||||
|
|
||||||
Assert.IsNotNull(permMapping, "PermissionContextsView is null");
|
Assert.IsNotNull(permMapping, "PermissionContextsView is null");
|
||||||
Assert.IsTrue(permMapping.Count > 0, "PermissionContextsView count: 0");
|
Assert.IsTrue(permMapping.Count != 0, "PermissionContextsView count: 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Product GetProductById_ReturnsProduct_WhenProductExists(string productIdString)
|
public Product GetProductById_ReturnsProduct_WhenProductExists(string productIdString)
|
||||||
|
|
@ -86,7 +75,7 @@ namespace TIAM.Database.Test
|
||||||
{
|
{
|
||||||
var product = GetProductById_ReturnsProduct_WhenProductExists(productIdString);
|
var product = GetProductById_ReturnsProduct_WhenProductExists(productIdString);
|
||||||
|
|
||||||
Assert.IsTrue(product.UserProductMappings.Count > 0, "UserProductMappings count: 0");
|
Assert.IsTrue(product.UserProductMappings.Count != 0, "UserProductMappings count: 0");
|
||||||
|
|
||||||
Assert.IsNotNull(product.UserProductMappings[0].User, "User is null");
|
Assert.IsNotNull(product.UserProductMappings[0].User, "User is null");
|
||||||
Assert.IsNotNull(product.ServiceProvider, "ServiceProvider is null");
|
Assert.IsNotNull(product.ServiceProvider, "ServiceProvider is null");
|
||||||
|
|
@ -102,14 +91,15 @@ namespace TIAM.Database.Test
|
||||||
Assert.IsNotNull(user);
|
Assert.IsNotNull(user);
|
||||||
|
|
||||||
Assert.IsTrue(user.Id == userId, "user.Id != userId");
|
Assert.IsTrue(user.Id == userId, "user.Id != userId");
|
||||||
Assert.IsTrue(user.UserProductMappings.Count > 0, "UserProductMappings count: 0");
|
Assert.IsTrue(user.UserProductMappings.Count != 0, "UserProductMappings count: 0");
|
||||||
|
|
||||||
Assert.IsNotNull(user.UserProductMappings[0].Product, "Product is null");
|
Assert.IsNotNull(user.UserProductMappings[0].Product, "Product is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
#region UserProductMapping
|
#region UserProductMapping
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow("a24bf07a-76a7-48a4-813f-4a77e515b2f3")]
|
//[DataRow("a24bf07a-76a7-48a4-813f-4a77e515b2f3")]
|
||||||
|
[DataRow("71392cfd-fb9c-45c1-9540-7be3782cf26a")]
|
||||||
public void GetUserProductMappingById_ReturnsUserProductMapping_WhenHasUserAndProductRelation(string userProductMappingIdString)
|
public void GetUserProductMappingById_ReturnsUserProductMapping_WhenHasUserAndProductRelation(string userProductMappingIdString)
|
||||||
{
|
{
|
||||||
var userProductMappingId = Guid.Parse(userProductMappingIdString);
|
var userProductMappingId = Guid.Parse(userProductMappingIdString);
|
||||||
|
|
@ -119,6 +109,7 @@ namespace TIAM.Database.Test
|
||||||
Assert.IsNotNull(userProductMapping.User, "User is null");
|
Assert.IsNotNull(userProductMapping.User, "User is null");
|
||||||
Assert.IsNotNull(userProductMapping.Product, "Product is null");
|
Assert.IsNotNull(userProductMapping.Product, "Product is null");
|
||||||
|
|
||||||
|
Assert.IsTrue(userProductMapping.Transfers?.Count != 0, "Transfers?.Count == 0");
|
||||||
Assert.IsTrue(userProductMapping.Id == userProductMappingId, "userProductMapping.Id != userProductMappingId");
|
Assert.IsTrue(userProductMapping.Id == userProductMappingId, "userProductMapping.Id != userProductMappingId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,6 +138,7 @@ namespace TIAM.Database.Test
|
||||||
Assert.IsNotNull(userProductMapping.JsonDetailModel, "User is null");
|
Assert.IsNotNull(userProductMapping.JsonDetailModel, "User is null");
|
||||||
Assert.IsNotNull(userProductMapping.JsonDetailModel.Cars, "Product is null");
|
Assert.IsNotNull(userProductMapping.JsonDetailModel.Cars, "Product is null");
|
||||||
|
|
||||||
|
Assert.IsTrue(userProductMapping.Transfers?.Count != 0);
|
||||||
Assert.IsTrue(userProductMapping.JsonDetailModel.Cars.Count == 1);
|
Assert.IsTrue(userProductMapping.JsonDetailModel.Cars.Count == 1);
|
||||||
Assert.IsTrue(userProductMapping.JsonDetailModel.Cars[0].UserProductCarId == userProductCarId, "userProductMapping.JsonDetailModel.Cars[0].UserProductCarId == userProductCarId");
|
Assert.IsTrue(userProductMapping.JsonDetailModel.Cars[0].UserProductCarId == userProductCarId, "userProductMapping.JsonDetailModel.Cars[0].UserProductCarId == userProductCarId");
|
||||||
}
|
}
|
||||||
|
|
@ -218,11 +210,11 @@ namespace TIAM.Database.Test
|
||||||
|
|
||||||
if (userId != Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00")) return; //csak az "540271F6.."-nek van product-ja! - J.
|
if (userId != Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00")) return; //csak az "540271F6.."-nek van product-ja! - J.
|
||||||
|
|
||||||
Assert.IsTrue(userModel.Products.Count > 0);
|
Assert.IsTrue(userModel.Products.Count != 0);
|
||||||
Assert.IsTrue(userModel.UserProductMappings.Count > 0);
|
Assert.IsTrue(userModel.UserProductMappings.Count != 0);
|
||||||
|
|
||||||
Assert.IsTrue(userModel.ServiceProviders.Count > 0);
|
Assert.IsTrue(userModel.ServiceProviders.Count != 0);
|
||||||
Assert.IsTrue(userModel.UserToServiceProviders.Count > 0);
|
Assert.IsTrue(userModel.UserToServiceProviders.Count != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
|
|
@ -245,11 +237,11 @@ namespace TIAM.Database.Test
|
||||||
|
|
||||||
if (userId != Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00")) return; //csak az "540271F6.."-nek van product-ja! - J.
|
if (userId != Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00")) return; //csak az "540271F6.."-nek van product-ja! - J.
|
||||||
|
|
||||||
Assert.IsTrue(user.Products.Count > 0);
|
Assert.IsTrue(user.Products.Count != 0);
|
||||||
Assert.IsTrue(user.UserProductMappings.Count > 0);
|
Assert.IsTrue(user.UserProductMappings.Count != 0);
|
||||||
|
|
||||||
Assert.IsTrue(user.ServiceProviders.Count > 0);
|
Assert.IsTrue(user.ServiceProviders.Count != 0);
|
||||||
Assert.IsTrue(user.UserToServiceProviders.Count > 0);
|
Assert.IsTrue(user.UserToServiceProviders.Count != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
@ -274,6 +266,8 @@ namespace TIAM.Database.Test
|
||||||
var transfer = Dal.GetTransferById(transferId);
|
var transfer = Dal.GetTransferById(transferId);
|
||||||
|
|
||||||
Assert.IsNotNull(transfer);
|
Assert.IsNotNull(transfer);
|
||||||
|
Assert.IsNotNull(transfer.UserProductMapping);
|
||||||
|
|
||||||
Assert.IsTrue(transfer.Id == transferId, "transfer.Id != transferId");
|
Assert.IsTrue(transfer.Id == transferId, "transfer.Id != transferId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -289,7 +283,7 @@ namespace TIAM.Database.Test
|
||||||
|
|
||||||
Assert.IsTrue(transferDestination.Id == transferDestinationId, "transferDestination.Id != transferDestinationId");
|
Assert.IsTrue(transferDestination.Id == transferDestinationId, "transferDestination.Id != transferDestinationId");
|
||||||
|
|
||||||
//Assert.IsTrue(user.UserProductMappings.Count > 0, "UserProductMappings count: 0");
|
//Assert.IsTrue(user.UserProductMappings.Count != 0, "UserProductMappings count: 0");
|
||||||
//Assert.IsNotNull(user.UserProductMappings[0].Product, "Product is null");
|
//Assert.IsNotNull(user.UserProductMappings[0].Product, "Product is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -327,6 +321,7 @@ namespace TIAM.Database.Test
|
||||||
transfer = Dal.GetTransferById(transferId);
|
transfer = Dal.GetTransferById(transferId);
|
||||||
|
|
||||||
Assert.IsNotNull(transfer);
|
Assert.IsNotNull(transfer);
|
||||||
|
Assert.IsNull(transfer.UserProductMapping);
|
||||||
|
|
||||||
transfer.Payed = true;
|
transfer.Payed = true;
|
||||||
transfer.UserProductToCarId = userProductToCarId;
|
transfer.UserProductToCarId = userProductToCarId;
|
||||||
|
|
@ -339,6 +334,8 @@ namespace TIAM.Database.Test
|
||||||
transfer = Dal.GetTransferById(transferId);
|
transfer = Dal.GetTransferById(transferId);
|
||||||
|
|
||||||
Assert.IsNotNull(transfer);
|
Assert.IsNotNull(transfer);
|
||||||
|
Assert.IsNotNull(transfer.UserProductMapping);
|
||||||
|
|
||||||
Assert.IsTrue(transfer.Payed);
|
Assert.IsTrue(transfer.Payed);
|
||||||
Assert.IsTrue(transfer.UserProductToCarId == userProductToCarId);
|
Assert.IsTrue(transfer.UserProductToCarId == userProductToCarId);
|
||||||
Assert.IsTrue(transfer.TransferStatusType == TransferStatusType.AssignedToDriver);
|
Assert.IsTrue(transfer.TransferStatusType == TransferStatusType.AssignedToDriver);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TIAM.Core\TIAM.Core.csproj" />
|
||||||
<ProjectReference Include="..\TIAM.Database\TIAM.Database.csproj" />
|
<ProjectReference Include="..\TIAM.Database\TIAM.Database.csproj" />
|
||||||
<ProjectReference Include="..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" />
|
<ProjectReference Include="..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" />
|
||||||
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
|
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using AyCode.Database.DbSets.Users;
|
using AyCode.Database.DbSets.Users;
|
||||||
using AyCode.Models.Enums;
|
using AyCode.Models.Enums;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using TIAM.Core;
|
||||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
//using TIAM.Database.DataLayers.ServiceProviders;
|
||||||
using TIAM.Database.DbContexts.Admins;
|
using TIAM.Database.DbContexts.Admins;
|
||||||
using TIAM.Database.DbSets.Permissions;
|
using TIAM.Database.DbSets.Permissions;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using TIAM.Core.Interfaces;
|
||||||
using TIAM.Database.DbContexts.Admins;
|
using TIAM.Database.DbContexts.Admins;
|
||||||
using TIAM.Database.DbContexts.ServiceProviders;
|
using TIAM.Database.DbContexts.ServiceProviders;
|
||||||
using TIAM.Database.DbSets.Permissions;
|
using TIAM.Database.DbSets.Permissions;
|
||||||
|
|
@ -19,28 +20,6 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
{
|
{
|
||||||
public static class AdminDalDbContextExtension
|
public static class AdminDalDbContextExtension
|
||||||
{
|
{
|
||||||
public static string ToJson<T>(this T source) where T : class, IEntity
|
|
||||||
{
|
|
||||||
JsonSerializerSettings options = new()
|
|
||||||
{
|
|
||||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
|
||||||
NullValueHandling = NullValueHandling.Ignore
|
|
||||||
};
|
|
||||||
|
|
||||||
return JsonConvert.SerializeObject(source, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string ToJson<T>(this IQueryable<T> source) where T : class, IEntity
|
|
||||||
{
|
|
||||||
JsonSerializerSettings options = new()
|
|
||||||
{
|
|
||||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
|
||||||
NullValueHandling = NullValueHandling.Ignore
|
|
||||||
};
|
|
||||||
|
|
||||||
return JsonConvert.SerializeObject(source, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IQueryable<UserProductMapping> GetUserProductMappingsByPermissionGroupId(this IAdminDbContext ctx, Guid permissionGroupId)
|
public static IQueryable<UserProductMapping> GetUserProductMappingsByPermissionGroupId(this IAdminDbContext ctx, Guid permissionGroupId)
|
||||||
{
|
{
|
||||||
return ctx.UserProductMappings
|
return ctx.UserProductMappings
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||||
using AyCode.Database.DbContexts;
|
using AyCode.Database.DbContexts;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using TIAM.Database.ModelBuilders.Products;
|
using TIAM.Database.ModelBuilders.Products;
|
||||||
|
using TIAM.Database.ModelBuilders.Transfers;
|
||||||
using TIAM.Database.ModelBuilders.Users;
|
using TIAM.Database.ModelBuilders.Users;
|
||||||
using TIAM.Entities.Addresses;
|
using TIAM.Entities.Addresses;
|
||||||
using TIAM.Entities.Drivers;
|
using TIAM.Entities.Drivers;
|
||||||
|
|
@ -55,9 +56,11 @@ namespace TIAM.Database.DbContexts.Admins
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>());
|
new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>());
|
||||||
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
||||||
|
|
||||||
new ProductEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<Product>());
|
new ProductEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<Product>());
|
||||||
|
|
||||||
|
new TransferEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<Transfer>());
|
||||||
modelBuilder.Entity<TransferDestination>().Navigation(e => e.Address).AutoInclude(true);
|
modelBuilder.Entity<TransferDestination>().Navigation(e => e.Address).AutoInclude(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
using TIAM.Database.ModelBuilders.Users;
|
||||||
|
using TIAM.Entities.Transfers;
|
||||||
|
using TIAM.Entities.Users;
|
||||||
|
|
||||||
|
namespace TIAM.Database.ModelBuilders.Transfers;
|
||||||
|
|
||||||
|
public static class TransferEntityTypeBuilderExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Mapping Transfer to UserProductMapping relation
|
||||||
|
/// </summary>
|
||||||
|
public static void BuildTransferToProductMappingToRelation(this EntityTypeBuilder<Transfer> modelBuilder, bool autoInclude)
|
||||||
|
{
|
||||||
|
modelBuilder
|
||||||
|
.HasOne(x => x.UserProductMapping)
|
||||||
|
.WithMany(x => x.Transfers)
|
||||||
|
.HasForeignKey(x => x.UserProductMappingId);
|
||||||
|
|
||||||
|
modelBuilder.Navigation(e => e.UserProductMapping).AutoInclude(autoInclude);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
using AyCode.Database.DbContexts;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
using TIAM.Entities.Products;
|
||||||
|
using TIAM.Entities.Transfers;
|
||||||
|
|
||||||
|
namespace TIAM.Database.ModelBuilders.Transfers;
|
||||||
|
|
||||||
|
public class TransferEntityTypeDefaultConfigurations: IAcEntityTypeConfiguration<Transfer>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<Transfer> builder)
|
||||||
|
{
|
||||||
|
builder.BuildTransferToProductMappingToRelation(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using AyCode.Interfaces.Profiles;
|
using AyCode.Interfaces.Profiles;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
|
using TIAM.Entities.Transfers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
|
|
||||||
namespace TIAM.Database.ModelBuilders.Users;
|
namespace TIAM.Database.ModelBuilders.Users;
|
||||||
|
|
@ -67,5 +68,17 @@ public static class UserEntityTypeBuilderExtensions
|
||||||
modelBuilder.Navigation(e => e.Product).AutoInclude(autoInclude);
|
modelBuilder.Navigation(e => e.Product).AutoInclude(autoInclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mapping User relation
|
||||||
|
/// </summary>
|
||||||
|
public static void BuildTransferToUserProductMappingRelation(this EntityTypeBuilder<UserProductMapping> modelBuilder, bool autoInclude)
|
||||||
|
{
|
||||||
|
modelBuilder
|
||||||
|
.HasMany(e => e.Transfers)
|
||||||
|
.WithOne(e => e.UserProductMapping).HasForeignKey(x => x.UserProductMappingId);
|
||||||
|
|
||||||
|
modelBuilder.Navigation(e => e.Transfers).AutoInclude(autoInclude);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion UserProductMapping
|
#endregion UserProductMapping
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using AyCode.Database.DbContexts;
|
using AyCode.Database.DbContexts;
|
||||||
using AyCode.Database.ModelBuilders.Users;
|
using AyCode.Database.ModelBuilders.Users;
|
||||||
using AyCode.Interfaces.Users;
|
using AyCode.Interfaces.Users;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
using TIAM.Entities.Profiles;
|
using TIAM.Entities.Profiles;
|
||||||
using TIAM.Entities.ServiceProviders;
|
using TIAM.Entities.ServiceProviders;
|
||||||
|
|
@ -13,9 +14,17 @@ public class UserProductMappingEntityTypeDefaultConfiguration : IAcEntityTypeCon
|
||||||
public void Configure(EntityTypeBuilder<UserProductMapping> builder)
|
public void Configure(EntityTypeBuilder<UserProductMapping> builder)
|
||||||
{
|
{
|
||||||
builder.BuildUserProductMappingToRelations(false);
|
builder.BuildUserProductMappingToRelations(false);
|
||||||
|
builder.BuildTransferToUserProductMappingRelation(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class UserProductMappingEntityTypeTransferConfiguration : IAcEntityTypeConfiguration<UserProductMapping>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<UserProductMapping> builder)
|
||||||
|
{
|
||||||
|
builder.BuildUserProductMappingToRelations(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
public class UserEntityTypeDefaultConfiguration : AcUserEntityTypeDefaultConfiguration<User, Profile, TiamServiceProvider, UserToServiceProvider> //IAcEntityTypeConfiguration<User>//
|
public class UserEntityTypeDefaultConfiguration : AcUserEntityTypeDefaultConfiguration<User, Profile, TiamServiceProvider, UserToServiceProvider> //IAcEntityTypeConfiguration<User>//
|
||||||
{
|
{
|
||||||
public override void Configure(EntityTypeBuilder<User> builder)
|
public override void Configure(EntityTypeBuilder<User> builder)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TIAM.Core\TIAM.Core.csproj" />
|
||||||
<ProjectReference Include="..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" />
|
<ProjectReference Include="..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" />
|
||||||
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
|
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
|
||||||
<ProjectReference Include="..\TIAM.Models\TIAM.Models.csproj" />
|
<ProjectReference Include="..\TIAM.Models\TIAM.Models.csproj" />
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using AyCode.Interfaces.Entities;
|
||||||
|
using AyCode.Interfaces.TimeStampInfo;
|
||||||
|
|
||||||
|
namespace TIAM.Entities.Emails;
|
||||||
|
|
||||||
|
[Table(nameof(EmailMessage))]
|
||||||
|
public class EmailMessage : IEntityGuid, ITimeStampInfo
|
||||||
|
{
|
||||||
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public Guid ForeignKey { get; set; }
|
||||||
|
public Guid UserProductMappingId { get; set; }
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
public bool SentToUser { get; set; }
|
||||||
|
[MaxLength(150)]
|
||||||
|
public string EmailAddress { get; set; }
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string Subject { get; set; }
|
||||||
|
public string Text { get; set; }
|
||||||
|
|
||||||
|
public DateTime Created { get; set; }
|
||||||
|
public DateTime Modified { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -6,18 +6,25 @@ using System.Text.Json.Serialization;
|
||||||
using TIAM.Core.Enums;
|
using TIAM.Core.Enums;
|
||||||
using TIAM.Entities.Drivers;
|
using TIAM.Entities.Drivers;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
|
using TIAM.Entities.Users;
|
||||||
|
|
||||||
namespace TIAM.Entities.Transfers;
|
namespace TIAM.Entities.Transfers;
|
||||||
|
|
||||||
[Table(nameof(Transfer))]
|
[Table(nameof(Transfer))]
|
||||||
public class Transfer: IEntityGuid, ITimeStampInfo, IProductForeignKey
|
public class Transfer: IEntityGuid, ITimeStampInfo, IProductForeignKey, IUserProductMappingForeignKey<Guid?>
|
||||||
{
|
{
|
||||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int OrderId { get; }
|
||||||
|
|
||||||
public Guid ProductId { get; set; }
|
public Guid ProductId { get; set; }
|
||||||
public Guid? UserProductMappingId { get; set; }
|
public Guid? UserProductMappingId { get; set; }
|
||||||
public Guid? UserProductToCarId { get; set; }
|
public Guid? UserProductToCarId { get; set; }
|
||||||
|
|
||||||
|
public virtual UserProductMapping? UserProductMapping { get; set; }
|
||||||
|
|
||||||
[Required] public TransferStatusType TransferStatusType { get; set; } = TransferStatusType.OrderSubmitted;
|
[Required] public TransferStatusType TransferStatusType { get; set; } = TransferStatusType.OrderSubmitted;
|
||||||
|
|
||||||
[Required] public DateTime Appointment { get; set; }
|
[Required] public DateTime Appointment { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace TIAM.Entities.Users;
|
||||||
|
|
||||||
|
public interface IUserProductMappingForeignKey<T>
|
||||||
|
{
|
||||||
|
public T UserProductMappingId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IUserProductMappingForeignKey : IUserProductMappingForeignKey<Guid>
|
||||||
|
{ }
|
||||||
|
|
@ -7,6 +7,7 @@ using AyCode.Interfaces.TimeStampInfo;
|
||||||
using AyCode.Interfaces.Users;
|
using AyCode.Interfaces.Users;
|
||||||
using TIAM.Entities.Drivers;
|
using TIAM.Entities.Drivers;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
|
using TIAM.Entities.Transfers;
|
||||||
|
|
||||||
namespace TIAM.Entities.Users;
|
namespace TIAM.Entities.Users;
|
||||||
|
|
||||||
|
|
@ -20,6 +21,7 @@ public class UserProductMapping : IEntityGuid, IUserForeignKey, IProductForeignK
|
||||||
|
|
||||||
public virtual User User { get; set; }
|
public virtual User User { get; set; }
|
||||||
public virtual Product Product { get; set; }
|
public virtual Product Product { get; set; }
|
||||||
|
public virtual List<Transfer>? Transfers { get; set; }
|
||||||
|
|
||||||
public int Permissions { get; set; } = 1;
|
public int Permissions { get; set; } = 1;
|
||||||
public bool IsAdmin { get; set; }
|
public bool IsAdmin { get; set; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue