Update efcore, aspnetcore to 8.0.1; Implement EmailMessage, EmailRecipient; refactoring, improvments, fixes, etc...
This commit is contained in:
parent
eccecc65e2
commit
2e1630913e
|
|
@ -5,7 +5,9 @@ using TIAM.Core;
|
|||
using TIAM.Core.Enums;
|
||||
using TIAM.Database.DataLayers.Admins;
|
||||
using TIAM.Database.DbContexts.Admins;
|
||||
using TIAM.Database.DbSets.Emails;
|
||||
using TIAM.Entities.Drivers;
|
||||
using TIAM.Entities.Emails;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
|
|
@ -371,7 +373,85 @@ namespace TIAM.Database.Test
|
|||
Assert.IsNull(transfer); //a korábbi törlés miatt NULL kell legyen - J.
|
||||
}
|
||||
|
||||
#endregion Trnsfer
|
||||
#endregion Transfer
|
||||
|
||||
#region EmailMessage
|
||||
[DataTestMethod]
|
||||
[DataRow("f6ec3eed-5e00-47db-a6cf-804699515aa2")]
|
||||
public async Task GetEmailMessageById_ReturnsEmailMessage_WhenHasEmailMessage(string emailMessageIdString)
|
||||
{
|
||||
var emailMessageId = Guid.Parse(emailMessageIdString);
|
||||
var emailMessage = await Dal.GetEmailMessageByIdAsync(emailMessageId);
|
||||
|
||||
Assert.IsNotNull(emailMessage);
|
||||
|
||||
Assert.IsTrue(emailMessage.Recipients?.Count > 0);
|
||||
Assert.IsTrue(emailMessage.Id == emailMessageId, "emailMessage.Id != emailMessageId");
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(["4CBAED43-2465-4D99-84F1-C8BC6B7025F7", "71392cfd-fb9c-45c1-9540-7be3782cf26a"])]
|
||||
public async Task GetMyEmailMessagesByUserProductMappingId_ReturnsEmailMessages_WhenHasEmailMessageAndAllRecipientIsValid(string[] userIdUserProductMappingIdString)
|
||||
{
|
||||
var userId = Guid.Parse(userIdUserProductMappingIdString[0]);
|
||||
var userProductMappingId = Guid.Parse(userIdUserProductMappingIdString[1]);
|
||||
|
||||
var emailMessages = await Dal.GetEmailMessagesAsync(userId, userProductMappingId);
|
||||
|
||||
Assert.IsNotNull(emailMessages);
|
||||
|
||||
Assert.IsTrue(emailMessages.Count > 0);
|
||||
Assert.IsTrue(emailMessages.All(x => x.Recipients.Any(recipient => recipient.RecipientId == userId || recipient.RecipientId == userProductMappingId)));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(["718b04ef-47a7-444e-8527-54460a7f1ea3", "71392cfd-fb9c-45c1-9540-7be3782cf26a", "6216f9fb-1dda-44bd-9d85-431f3cb09fde", "test@tiam.hu", "AC612AA8-863B-4B4F-9D63-F5D261B5C5F9"])]
|
||||
public async Task EmailMessageCrudTest(string[] emailIdSenderIdContextIdSenderEmailRecipientIdStrings)
|
||||
{
|
||||
var emailMessageId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[0]);
|
||||
var senderId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[1]);
|
||||
var contextId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[2]);
|
||||
var senderEmail = emailIdSenderIdContextIdSenderEmailRecipientIdStrings[3];
|
||||
var recipientId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[4]);
|
||||
|
||||
var subject = "Transfer - Budapest, Liszt Ferenc tér";
|
||||
var text = "1211 Budapest, Kossuth Lajos utca 145";
|
||||
|
||||
await Dal.RemoveEmailMessageAsync(emailMessageId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
|
||||
|
||||
var emailMessage = new EmailMessage(emailMessageId, senderId, contextId, subject, text, senderEmail);
|
||||
emailMessage.Recipients.Add(new EmailRecipient(id: Guid.NewGuid(), recipientId, emailMessageId));
|
||||
|
||||
|
||||
Assert.IsTrue(await Dal.AddEmailMessageAsync(emailMessage));
|
||||
Assert.IsNotNull(emailMessage);
|
||||
|
||||
emailMessage = await Dal.GetEmailMessageByIdAsync(emailMessageId);
|
||||
|
||||
Assert.IsNotNull(emailMessage);
|
||||
Assert.IsTrue(emailMessage.Recipients?.Count > 0);
|
||||
|
||||
var modifiedText = "modifiedText";
|
||||
emailMessage.Text = modifiedText;
|
||||
|
||||
|
||||
Assert.IsTrue(await Dal.UpdateEmailMessageAsync(emailMessage));
|
||||
|
||||
emailMessage = await Dal.GetEmailMessageByIdAsync(emailMessageId);
|
||||
|
||||
Assert.IsNotNull(emailMessage);
|
||||
Assert.IsTrue(emailMessage.Recipients?.Count > 0);
|
||||
|
||||
Assert.IsTrue(emailMessage.Text == modifiedText);
|
||||
Assert.IsTrue(emailMessage.Id == emailMessageId, "emailMessage.Id != emailMessageId");
|
||||
|
||||
Assert.IsTrue(await Dal.RemoveEmailMessageAsync(emailMessageId)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
||||
|
||||
emailMessage = await Dal.GetEmailMessageByIdAsync(emailMessageId);
|
||||
Assert.IsNull(emailMessage); //a korábbi törlés miatt NULL kell legyen - J.
|
||||
}
|
||||
|
||||
#endregion EmailMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -10,10 +10,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using TIAM.Core;
|
||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
||||
using TIAM.Database.DbContexts.Admins;
|
||||
using TIAM.Database.DbSets.Emails;
|
||||
using TIAM.Database.DbSets.Permissions;
|
||||
using TIAM.Database.DbSets.Products;
|
||||
using TIAM.Database.DbSets.Transfers;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Drivers;
|
||||
using TIAM.Entities.Emails;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
|
|
@ -78,7 +80,7 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
|
||||
#region UserProductMapping
|
||||
public Task<bool> AddUserProductMappingAsync(UserProductMapping userProductMapping)
|
||||
=> TransactionAsync(ctx => ctx.AddUserProductMapping(userProductMapping) && ctx.SaveChanges() == 1);
|
||||
=> TransactionAsync(ctx => ctx.AddUserProductMapping(userProductMapping) && ctx.SaveChanges() > 0);
|
||||
|
||||
public async Task<UserProductMapping?> AddUserProductMappingAsync(Guid userProductMappingId, Guid userId, Guid productId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
|
||||
{
|
||||
|
|
@ -88,7 +90,7 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
{
|
||||
userProductMapping = ctx.AddUserProductMapping(userProductMappingId, userId, productId, permissions, userProductToCars);
|
||||
|
||||
return userProductMapping != null && ctx.SaveChanges() == 1;
|
||||
return userProductMapping != null && ctx.SaveChanges() > 0;
|
||||
});
|
||||
|
||||
return isSucces ? userProductMapping : null;
|
||||
|
|
@ -105,20 +107,40 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
{
|
||||
userProductMapping = ctx.UpdateUserProductMapping(userProductMappingId, permissions, userProductToCars);
|
||||
|
||||
return userProductMapping != null && ctx.SaveChanges() == 1;
|
||||
return userProductMapping != null && ctx.SaveChanges() > 0;
|
||||
});
|
||||
|
||||
return isSucces ? userProductMapping : null;
|
||||
}
|
||||
|
||||
public Task<bool> RemoveUserProductMappingAsync(Guid userProductMappingId)
|
||||
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userProductMappingId) && ctx.SaveChanges() == 1);
|
||||
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userProductMappingId) && ctx.SaveChanges() > 0);
|
||||
|
||||
public Task<bool> RemoveUserProductMappingAsync(Guid userId, Guid productId)
|
||||
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userId, productId) && ctx.SaveChanges() == 1);
|
||||
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userId, productId) && ctx.SaveChanges() > 0);
|
||||
|
||||
#endregion UserProductMapping
|
||||
|
||||
#region EmailMessage
|
||||
public Task<EmailMessage?> GetEmailMessageByIdAsync(Guid emailMessageId) => SessionAsync(ctx => ctx.GetEmailMessageById(emailMessageId));
|
||||
public Task<List<EmailMessage>> GetEmailMessagesByContextIdAsync(Guid contextId) => SessionAsync(ctx => ctx.GetEmailMessagesByContextId(contextId).ToList());
|
||||
public Task<List<EmailMessage>> GetEmailMessagesBySenderIdAsync(Guid senderId) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderId(senderId).ToList());
|
||||
public Task<List<EmailMessage>> GetEmailMessagesBySenderEmailAddressAsync(string emailAddress) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderEmailAddress(emailAddress).ToList());
|
||||
public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages(userId, userProductMappingId).ToList());
|
||||
public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid contextId, Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages(contextId, userId, userProductMappingId).ToList());
|
||||
|
||||
|
||||
public Task<bool> AddEmailMessageAsync(EmailMessage emailMessage)
|
||||
=> TransactionAsync(ctx => ctx.AddEmailMessage(emailMessage) && ctx.SaveChanges() > 0);
|
||||
|
||||
public Task<bool> UpdateEmailMessageAsync(EmailMessage emailMessage)
|
||||
=> TransactionAsync(ctx => ctx.UpdateEmailMessage(emailMessage) && ctx.SaveChanges() > 0);
|
||||
|
||||
public Task<bool> RemoveEmailMessageAsync(Guid emailMessageId)
|
||||
=> TransactionAsync(ctx => ctx.RemoveEmailMessage(emailMessageId) && ctx.SaveChanges() > 0);
|
||||
|
||||
#endregion EmailMessage
|
||||
|
||||
//15. (IServiceProviderDataService) Create service provider
|
||||
public Task<bool> CreateServiceProviderAsync(TiamServiceProvider serviceProvider)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using AyCode.Database.DbContexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Database.ModelBuilders.Emails;
|
||||
using TIAM.Database.ModelBuilders.Products;
|
||||
using TIAM.Database.ModelBuilders.Transfers;
|
||||
using TIAM.Database.ModelBuilders.Users;
|
||||
using TIAM.Entities.Addresses;
|
||||
using TIAM.Entities.Drivers;
|
||||
using TIAM.Entities.Emails;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
|
|
@ -32,6 +34,9 @@ namespace TIAM.Database.DbContexts.Admins
|
|||
public DbSet<PermissionGroupUserMapping> PermissionGroupUserMappings { get; set; }
|
||||
public DbSet<PermissionContextMapping> PermissionContextMappings { get; set; }
|
||||
public DbSet<PermissionsType> PermissionsTypes { get; set; }
|
||||
|
||||
public DbSet<EmailMessage> EmailMessages { get; set; }
|
||||
|
||||
public DbSet<Address> Addresses { get; set; }
|
||||
|
||||
public AdminDbContext() //: this(string.Empty)
|
||||
|
|
@ -63,6 +68,7 @@ namespace TIAM.Database.DbContexts.Admins
|
|||
new TransferEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<Transfer>());
|
||||
modelBuilder.Entity<TransferDestination>().Navigation(e => e.Address).AutoInclude(true);
|
||||
|
||||
new EmailMessageEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<EmailMessage>());
|
||||
|
||||
//modelBuilder.Entity<UserProductToCar>().Ignore(x => x.Id);
|
||||
//modelBuilder.Entity<Car>().Ignore(x => x.Id);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using TIAM.Database.DbSets.Addresses;
|
||||
using TIAM.Database.DbSets.Emails;
|
||||
using TIAM.Database.DbSets.Permissions;
|
||||
using TIAM.Database.DbSets.Products;
|
||||
using TIAM.Database.DbSets.ServiceProvider;
|
||||
|
|
@ -7,6 +8,7 @@ using TIAM.Database.DbSets.Users;
|
|||
|
||||
namespace TIAM.Database.DbContexts.Admins;
|
||||
|
||||
public interface IAdminDbContext : IServiceProviderDbSet, IProductDbSet, IUserProductMappingDbSet, IUserDbSet, IPermissionsDbSetContext, IAddressDbSet, ITransferDestinationDbSet, ITransferDbSet
|
||||
public interface IAdminDbContext :
|
||||
IServiceProviderDbSet, IProductDbSet, IUserProductMappingDbSet, IUserDbSet, IPermissionsDbSetContext, IAddressDbSet, ITransferDestinationDbSet, ITransferDbSet, IEmailMessageDbSet
|
||||
{
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using AyCode.Database.DbContexts.Users;
|
||||
using AyCode.Entities.Users;
|
||||
using TIAM.Database.DbSets.Addresses;
|
||||
using TIAM.Database.DbSets.Emails;
|
||||
using TIAM.Database.DbSets.Transfers;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Addresses;
|
||||
|
|
@ -10,6 +11,6 @@ using TIAM.Entities.Users;
|
|||
|
||||
namespace TIAM.Database.DbContexts.Users;
|
||||
|
||||
public interface IUserDbContext : IAcUserDbContextBase<User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider>, IUserDbSet, IAddressDbSet, ITransferDestinationDbSet
|
||||
{
|
||||
}
|
||||
public interface IUserDbContext :
|
||||
IAcUserDbContextBase<User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider>, IUserDbSet, IAddressDbSet, ITransferDestinationDbSet, ITransferDbSet, IEmailMessageDbSet
|
||||
{ }
|
||||
|
|
@ -11,12 +11,16 @@ using AyCode.Entities.Users;
|
|||
using AyCode.Interfaces.Users;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using TIAM.Database.ModelBuilders.Emails;
|
||||
using TIAM.Database.ModelBuilders.Products;
|
||||
using TIAM.Database.ModelBuilders.Transfers;
|
||||
using TIAM.Database.ModelBuilders.Users;
|
||||
using TIAM.Entities.Addresses;
|
||||
using TIAM.Entities.Emails;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.TransferDestinations;
|
||||
using TIAM.Entities.Transfers;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.DbContexts.Users
|
||||
|
|
@ -27,7 +31,11 @@ namespace TIAM.Database.DbContexts.Users
|
|||
public DbSet<UserToken> UserTokens { get; set; }
|
||||
|
||||
public DbSet<Address> Addresses { get; set; }
|
||||
public DbSet<TransferDestination> TransferDestinations { get; }
|
||||
|
||||
public DbSet<Transfer> Transfers { get; set; }
|
||||
public DbSet<EmailMessage> EmailMessages { get; set; }
|
||||
|
||||
public DbSet<TransferDestination> TransferDestinations { get; set; }
|
||||
|
||||
public UserDbContext() //: this(string.Empty)
|
||||
{
|
||||
|
|
@ -59,8 +67,12 @@ namespace TIAM.Database.DbContexts.Users
|
|||
new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>());
|
||||
new ProductEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<Product>());
|
||||
|
||||
new TransferEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<Transfer>());
|
||||
modelBuilder.Entity<TransferDestination>().Navigation(e => e.Address).AutoInclude(true);
|
||||
|
||||
new EmailMessageEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<EmailMessage>());
|
||||
|
||||
|
||||
//modelBuilder.Entity<Product>().BuildProductToServiceProviderRelation();
|
||||
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Entities.Emails;
|
||||
using TIAM.Entities.Products;
|
||||
|
||||
namespace TIAM.Database.DbSets.Emails;
|
||||
|
||||
public static class EmailMessageDbSetExtension
|
||||
{
|
||||
public static EmailMessage? GetEmailMessageById(this IEmailMessageDbSet ctx, Guid emailMessageId)
|
||||
=> ctx.EmailMessages.FirstOrDefault(x => x.Id == emailMessageId);
|
||||
|
||||
public static IQueryable<EmailMessage> GetEmailMessagesByContextId(this IEmailMessageDbSet ctx, Guid contextId)
|
||||
=> ctx.EmailMessages.Where(x => x.ContextId == contextId);
|
||||
|
||||
public static IQueryable<EmailMessage> GetEmailMessagesBySenderId(this IEmailMessageDbSet ctx, Guid senderId)
|
||||
=> ctx.EmailMessages.Where(x => x.SenderId == senderId);
|
||||
|
||||
public static IQueryable<EmailMessage> GetEmailMessagesBySenderEmailAddress(this IEmailMessageDbSet ctx, string senderEmailAddress)
|
||||
=> ctx.EmailMessages.Where(x => x.SenderEmailAddress == senderEmailAddress);
|
||||
|
||||
private static IQueryable<EmailMessage> GetEmailMessages(this IQueryable<EmailMessage> queryableEmails, Guid userId, Guid userProductMappingId)
|
||||
=> queryableEmails.Where(x => x.SenderId == userId || x.SenderId == userProductMappingId || x.Recipients.Any(recipient => recipient.RecipientId == userId || recipient.RecipientId == userProductMappingId));
|
||||
|
||||
public static IQueryable<EmailMessage> GetEmailMessages(this IEmailMessageDbSet ctx, Guid userId, Guid userProductMappingId)
|
||||
=> ctx.EmailMessages.GetEmailMessages(userId, userProductMappingId);
|
||||
|
||||
public static IQueryable<EmailMessage> GetEmailMessages(this IEmailMessageDbSet ctx, Guid contextId, Guid userId, Guid userProductMappingId)
|
||||
=> ctx.GetEmailMessagesByContextId(contextId).GetEmailMessages(userId, userProductMappingId);
|
||||
|
||||
#region Add, Update, Remove
|
||||
|
||||
public static bool AddEmailMessage(this IEmailMessageDbSet ctx, EmailMessage emailMessage)
|
||||
=> ctx.EmailMessages.Add(emailMessage).State == EntityState.Added;
|
||||
|
||||
public static bool UpdateEmailMessage(this IEmailMessageDbSet ctx, EmailMessage emailMessage)
|
||||
=> ctx.EmailMessages.Update(emailMessage).State == EntityState.Modified;
|
||||
|
||||
public static bool RemoveEmailMessage(this IEmailMessageDbSet ctx, Guid emailMessageId)
|
||||
{
|
||||
var emailMessage = ctx.GetEmailMessageById(emailMessageId);
|
||||
|
||||
return emailMessage == null || ctx.RemoveEmailMessage(emailMessage);
|
||||
}
|
||||
|
||||
public static bool RemoveEmailMessage(this IEmailMessageDbSet ctx, EmailMessage emailMessage)
|
||||
=> ctx.EmailMessages.Remove(emailMessage).State == EntityState.Deleted;
|
||||
|
||||
#endregion Add, Update, Remove
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Entities.Emails;
|
||||
using TIAM.Entities.Permissions;
|
||||
|
||||
namespace TIAM.Database.DbSets.Emails;
|
||||
|
||||
public interface IEmailMessageDbSet
|
||||
{
|
||||
public DbSet<EmailMessage> EmailMessages { get; set; }
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ using TIAM.Entities.Products;
|
|||
|
||||
namespace TIAM.Database.DbSets.Products;
|
||||
|
||||
public static class ProductDbSetExtensins
|
||||
public static class ProductDbSetExtensions
|
||||
{
|
||||
#region Add, Update, Remove
|
||||
|
||||
|
|
@ -6,5 +6,5 @@ namespace TIAM.Database.DbSets.Transfers;
|
|||
|
||||
public interface ITransferDbSet
|
||||
{
|
||||
public DbSet<Transfer> Transfers { get; }
|
||||
public DbSet<Transfer> Transfers { get; set; }
|
||||
}
|
||||
|
|
@ -6,5 +6,5 @@ namespace TIAM.Database.DbSets.Transfers;
|
|||
|
||||
public interface ITransferDestinationDbSet
|
||||
{
|
||||
public DbSet<TransferDestination> TransferDestinations { get; }
|
||||
public DbSet<TransferDestination> TransferDestinations { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using TIAM.Entities.Emails;
|
||||
|
||||
namespace TIAM.Database.ModelBuilders.Emails;
|
||||
|
||||
public static class EmailMessageEntityTypeBuilderExtensions
|
||||
{
|
||||
public static void BuildEmailMessageToRecipientRelation(this EntityTypeBuilder<EmailMessage> modelBuilder, bool autoInclude = true)
|
||||
{
|
||||
modelBuilder
|
||||
.HasMany(x => x.Recipients)
|
||||
.WithOne(x => x.EmailMessage);
|
||||
|
||||
modelBuilder.Navigation(e => e.Recipients).AutoInclude(autoInclude);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using AyCode.Database.DbContexts;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using TIAM.Database.ModelBuilders.Products;
|
||||
using TIAM.Entities.Emails;
|
||||
using TIAM.Entities.Products;
|
||||
|
||||
namespace TIAM.Database.ModelBuilders.Emails;
|
||||
|
||||
public class EmailMessageEntityTypeDefaultConfigurations : IAcEntityTypeConfiguration<EmailMessage>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<EmailMessage> builder)
|
||||
{
|
||||
builder.BuildEmailMessageToRecipientRelation();
|
||||
}
|
||||
}
|
||||
|
|
@ -7,9 +7,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
<Folder Include="DbSets\Addresses\" />
|
||||
<Folder Include="DbSets\ServiceProvider\" />
|
||||
<Folder Include="Extensions\" />
|
||||
<Folder Include="ModelBuilders\Emails\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -7,21 +7,35 @@ using AyCode.Interfaces.TimeStampInfo;
|
|||
namespace TIAM.Entities.Emails;
|
||||
|
||||
[Table(nameof(EmailMessage))]
|
||||
public class EmailMessage : IEntityGuid, ITimeStampInfo
|
||||
public class EmailMessage : IEntityGuid, ITimeStampInfo, IEmailRecipientsRelation
|
||||
{
|
||||
public EmailMessage()
|
||||
{
|
||||
}
|
||||
|
||||
public EmailMessage(Guid id, Guid? senderId, Guid contextId, string subject, string? text, string senderEmailAddress) : this()
|
||||
{
|
||||
Id = id;
|
||||
SenderId = senderId;
|
||||
ContextId = contextId;
|
||||
Subject = subject;
|
||||
Text = text;
|
||||
SenderEmailAddress = senderEmailAddress;
|
||||
}
|
||||
|
||||
[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 Guid ContextId { get; set; }
|
||||
public Guid? SenderId { get; set; }
|
||||
|
||||
public virtual List<EmailRecipient> Recipients { get; set; } = [];
|
||||
|
||||
public bool SentToUser { get; set; }
|
||||
[MaxLength(150)]
|
||||
public string EmailAddress { get; set; }
|
||||
public string SenderEmailAddress { get; set; }
|
||||
[MaxLength(100)]
|
||||
public string Subject { get; set; }
|
||||
public string Text { get; set; }
|
||||
public string? Text { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace TIAM.Entities.Emails;
|
||||
|
||||
//Update efcore, aspnetcore to 8.0.1; Implement EmailMessage, EmailRecipient; refactoring, improvments, fixes, etc...
|
||||
public class EmailRecipient : IEntityGuid, ITimeStampInfo, IEmailMessageRelation
|
||||
{
|
||||
public EmailRecipient()
|
||||
{
|
||||
}
|
||||
|
||||
public EmailRecipient(Guid id, Guid recipientId, Guid emailMessageId) : this()
|
||||
{
|
||||
Id = id;
|
||||
RecipientId = recipientId;
|
||||
EmailMessageId = emailMessageId;
|
||||
}
|
||||
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid RecipientId { get; set; }
|
||||
public Guid EmailMessageId { get; set; }
|
||||
public virtual EmailMessage EmailMessage { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
namespace TIAM.Entities.Emails;
|
||||
|
||||
public interface IEmailMessageForeignKey<T>
|
||||
{
|
||||
public T EmailMessageId { get; set; }
|
||||
}
|
||||
|
||||
public interface IEmailMessageForeignKey : IEmailMessageForeignKey<Guid>
|
||||
{ }
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
namespace TIAM.Entities.Emails;
|
||||
|
||||
public interface IEmailMessageRelation : IEmailMessageForeignKey
|
||||
{
|
||||
public EmailMessage EmailMessage{ get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
namespace TIAM.Entities.Emails;
|
||||
|
||||
public interface IEmailRecipientsRelation
|
||||
{
|
||||
public List<EmailRecipient> Recipients { get; set; }
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
namespace TIAM.Entities.Products;
|
||||
|
||||
public interface IProductForeignKey<T>
|
||||
public interface IEmailMessageForeignKey<T>
|
||||
{
|
||||
public T ProductId { get; set; }
|
||||
}
|
||||
|
||||
public interface IProductForeignKey : IProductForeignKey<Guid>
|
||||
public interface IProductForeignKey : IEmailMessageForeignKey<Guid>
|
||||
{ }
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
using AyCode.Interfaces.ServiceProviders;
|
||||
using AyCode.Interfaces.Users;
|
||||
using TIAM.Entities.Users;
|
||||
namespace TIAM.Entities.Products;
|
||||
|
||||
namespace TIAM.Entities.Products;
|
||||
|
||||
public interface IProductRelation
|
||||
public interface IProductRelation : IProductForeignKey
|
||||
{
|
||||
public List<UserProductMapping> UserProductMappings { get; set; }
|
||||
public List<Product> Products { get; set; }
|
||||
|
||||
public Product Product { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using AyCode.Interfaces.ServiceProviders;
|
||||
using AyCode.Interfaces.Users;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Entities.Products;
|
||||
|
||||
public interface IProductsRelation
|
||||
{
|
||||
public List<UserProductMapping> UserProductMappings { get; set; }
|
||||
public List<Product> Products { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
using AyCode.Interfaces.Profiles;
|
||||
|
||||
namespace TIAM.Entities.Profiles;
|
||||
|
||||
public interface IProfileForeignKey : IAcProfileForeignKey
|
||||
{
|
||||
}
|
||||
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
namespace TIAM.Entities.Profiles;
|
||||
|
||||
public interface IProfileRelation : IAcProfileRelation<Profile>
|
||||
public interface IProfileRelation : IAcProfileRelation<Profile>, IProfileForeignKey
|
||||
{
|
||||
}
|
||||
|
|
@ -32,11 +32,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Emails\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ using TIAM.Entities.Users;
|
|||
namespace TIAM.Entities.Transfers;
|
||||
|
||||
[Table(nameof(Transfer))]
|
||||
public class Transfer: IEntityGuid, ITimeStampInfo, IProductForeignKey, IUserProductMappingForeignKey<Guid?>
|
||||
public class Transfer: IEntityGuid, ITimeStampInfo, IProductForeignKey, IUserProductMappingRelation<Guid?>
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
using AyCode.Interfaces.Users;
|
||||
|
||||
namespace TIAM.Entities.Users;
|
||||
|
||||
public interface IUserForeignKey : IAcUserForeignKey
|
||||
{
|
||||
}
|
||||
|
||||
public interface IUserRelation : IAcUserRelation<User>, IUserForeignKey
|
||||
{
|
||||
}
|
||||
|
||||
public interface IUsersRelation : IAcUsersRelation<User, UserToServiceProvider>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
namespace TIAM.Entities.Users;
|
||||
using System.Runtime;
|
||||
|
||||
namespace TIAM.Entities.Users;
|
||||
|
||||
public interface IUserProductMappingForeignKey<T>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
namespace TIAM.Entities.Users;
|
||||
|
||||
public interface IUserProductMappingRelation<T> : IUserProductMappingForeignKey<T>
|
||||
{
|
||||
public UserProductMapping UserProductMapping { get; set; }
|
||||
}
|
||||
|
||||
public interface IUserProductMappingsRelation : IUserProductMappingRelation<Guid>
|
||||
{ }
|
||||
|
|
@ -12,7 +12,7 @@ using TIAM.Entities.Transfers;
|
|||
namespace TIAM.Entities.Users;
|
||||
|
||||
[Table("UserProductMapping")]
|
||||
public class UserProductMapping : IEntityGuid, IUserForeignKey, IProductForeignKey, ITimeStampInfo
|
||||
public class UserProductMapping : IEntityGuid, IUserRelation, IProductRelation, ITimeStampInfo
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public Guid Id { get; set; }
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using TIAM.Models.Dtos.Profiles;
|
|||
|
||||
namespace TIAM.Models.Dtos.Users;
|
||||
|
||||
public class UserModelDto : AcUserModelDtoBase<UserDto, Profile, ProfileDto, TiamServiceProvider, UserToServiceProvider>, IProductRelation
|
||||
public class UserModelDto : AcUserModelDtoBase<UserDto, Profile, ProfileDto, TiamServiceProvider, UserToServiceProvider>, IProductsRelation
|
||||
{
|
||||
public List<UserProductMapping> UserProductMappings { get; set; }
|
||||
public List<Product> Products { get; set; }
|
||||
|
|
|
|||
|
|
@ -79,4 +79,16 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.AspNetCore.Components.WebView.Maui" Version="8.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
<PackageReference Include="Blazor.AnimateOnScroll" Version="1.1.0" />
|
||||
<PackageReference Include="BlazorAnimation" Version="2.2.0" />
|
||||
<PackageReference Include="DevExpress.Blazor" Version="23.2.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.1" PrivateAssets="all" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.7" />
|
||||
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GoogleApi" Version="5.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.6.11" />
|
||||
<PackageReference Include="GoogleApi" Version="5.3.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.6.12" />
|
||||
<PackageReference Include="QRCoderNetCore" Version="1.0.0" />
|
||||
<PackageReference Include="SendGrid" Version="9.28.1" />
|
||||
<PackageReference Include="SendGrid" Version="9.29.1" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.7" />
|
||||
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
using AyCode.Models.Enums;
|
||||
using AyCode.Models.Messages;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AyCode.Models.Messages;
|
||||
|
||||
namespace TIAMWebApp.Shared.Application.Models.ClientSide.Messages
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.JSInterop" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.JSInterop" Version="8.0.1" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.7" />
|
||||
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in New Issue