Merge
This commit is contained in:
commit
aaff1bfcb2
|
|
@ -6,6 +6,7 @@ using TIAM.Core.Enums;
|
||||||
using TIAM.Database.DataLayers.Admins;
|
using TIAM.Database.DataLayers.Admins;
|
||||||
using TIAM.Database.DbContexts.Admins;
|
using TIAM.Database.DbContexts.Admins;
|
||||||
using TIAM.Database.DbSets.Emails;
|
using TIAM.Database.DbSets.Emails;
|
||||||
|
using TIAM.Entities.Addresses;
|
||||||
using TIAM.Entities.Drivers;
|
using TIAM.Entities.Drivers;
|
||||||
using TIAM.Entities.Emails;
|
using TIAM.Entities.Emails;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
|
|
@ -324,6 +325,7 @@ namespace TIAM.Database.Test
|
||||||
//Assert.IsNotNull(user.UserProductMappings[0].Product, "Product is null");
|
//Assert.IsNotNull(user.UserProductMappings[0].Product, "Product is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow(["8f38f8e3-a92c-4979-88b1-dc812a82245f", "814b5495-c2e9-4f1d-a73f-37cd5d353078", "71392CFD-FB9C-45C1-9540-7BE3782CF26A"])]
|
[DataRow(["8f38f8e3-a92c-4979-88b1-dc812a82245f", "814b5495-c2e9-4f1d-a73f-37cd5d353078", "71392CFD-FB9C-45C1-9540-7BE3782CF26A"])]
|
||||||
public async Task TransferCrudTest(string[] transferIdProductIdUserProductIdStrings)
|
public async Task TransferCrudTest(string[] transferIdProductIdUserProductIdStrings)
|
||||||
|
|
@ -384,6 +386,67 @@ namespace TIAM.Database.Test
|
||||||
Assert.IsNull(transfer); //a korábbi törlés miatt NULL kell legyen - J.
|
Assert.IsNull(transfer); //a korábbi törlés miatt NULL kell legyen - J.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DataTestMethod]
|
||||||
|
[DataRow(["069089cd-66d4-4f0d-851b-2eea14fa62a4", "be709d9b-87dc-4c94-bf9e-d6254db3fa3e"])]
|
||||||
|
public async Task TransferDestinationCrudTest(string[] transferDestIdaddressIdStrings)
|
||||||
|
{
|
||||||
|
var transferDestId = Guid.Parse(transferDestIdaddressIdStrings[0]);
|
||||||
|
var addressId = Guid.Parse(transferDestIdaddressIdStrings[1]);
|
||||||
|
|
||||||
|
var name = "Liszt Ferenc repülőtér";
|
||||||
|
var address = "Budapest, Liszt Ferenc tér";
|
||||||
|
var modifiedAddress = "modified; " + address;
|
||||||
|
|
||||||
|
await Dal.RemoveTransferDestinationAsync(transferDestId, true); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
|
||||||
|
|
||||||
|
var transferDest = new TransferDestination
|
||||||
|
{
|
||||||
|
Id = transferDestId,
|
||||||
|
AddressId = addressId,
|
||||||
|
Name = name,
|
||||||
|
Description = name + "description",
|
||||||
|
Price = 15000,
|
||||||
|
Price2 = 21000,
|
||||||
|
Price3 = 23000,
|
||||||
|
PriceType = PriceType.Fix,
|
||||||
|
Address = new Address
|
||||||
|
{
|
||||||
|
Id = addressId,
|
||||||
|
AddressText = address,
|
||||||
|
IsValid = false,
|
||||||
|
IsHelper = false,
|
||||||
|
Latitude = new Random().NextDouble() + 42d,
|
||||||
|
Longitude = new Random().NextDouble() + 19d
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Assert.IsTrue(await Dal.AddTransferDestinationAsync(transferDest));
|
||||||
|
Assert.IsNotNull(transferDest);
|
||||||
|
|
||||||
|
transferDest = Dal.GetTransferDestinationById(transferDestId);
|
||||||
|
|
||||||
|
Assert.IsNotNull(transferDest);
|
||||||
|
Assert.IsNotNull(transferDest.Address);
|
||||||
|
|
||||||
|
transferDest.Price = 20000;
|
||||||
|
transferDest.Address.AddressText = modifiedAddress;
|
||||||
|
|
||||||
|
Assert.IsTrue(await Dal.UpdateTransferDestinationAsync(transferDest));
|
||||||
|
|
||||||
|
transferDest = Dal.GetTransferDestinationById(transferDestId);
|
||||||
|
|
||||||
|
Assert.IsNotNull(transferDest);
|
||||||
|
Assert.IsNotNull(transferDest.Address);
|
||||||
|
|
||||||
|
Assert.IsTrue(transferDest.Price == 20000);
|
||||||
|
Assert.IsTrue(transferDest.Address.AddressText == modifiedAddress);
|
||||||
|
Assert.IsTrue(transferDest.Id == transferDestId, "transferDest.Id != transferDestId");
|
||||||
|
|
||||||
|
Assert.IsTrue(await Dal.RemoveTransferDestinationAsync(transferDestId, true)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
||||||
|
|
||||||
|
transferDest = Dal.GetTransferDestinationById(transferDestId);
|
||||||
|
Assert.IsNull(transferDest); //a korábbi törlés miatt NULL kell legyen - J.
|
||||||
|
}
|
||||||
#endregion Transfer
|
#endregion Transfer
|
||||||
|
|
||||||
#region EmailMessage
|
#region EmailMessage
|
||||||
|
|
@ -424,6 +487,7 @@ namespace TIAM.Database.Test
|
||||||
var contextId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[2]);
|
var contextId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[2]);
|
||||||
var senderEmail = emailIdSenderIdContextIdSenderEmailRecipientIdStrings[3];
|
var senderEmail = emailIdSenderIdContextIdSenderEmailRecipientIdStrings[3];
|
||||||
var recipientId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[4]);
|
var recipientId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[4]);
|
||||||
|
var recipientEmail = "info@touriam.com";
|
||||||
|
|
||||||
var subject = "Transfer - Budapest, Liszt Ferenc tér";
|
var subject = "Transfer - Budapest, Liszt Ferenc tér";
|
||||||
var text = "1211 Budapest, Kossuth Lajos utca 145";
|
var text = "1211 Budapest, Kossuth Lajos utca 145";
|
||||||
|
|
@ -431,7 +495,7 @@ namespace TIAM.Database.Test
|
||||||
await Dal.RemoveEmailMessageAsync(emailMessageId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
|
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);
|
var emailMessage = new EmailMessage(emailMessageId, senderId, contextId, subject, text, senderEmail);
|
||||||
emailMessage.Recipients.Add(new EmailRecipient(id: Guid.NewGuid(), recipientId, emailMessageId));
|
emailMessage.Recipients.Add(new EmailRecipient(id: Guid.NewGuid(), recipientId, emailMessageId, recipientEmail));
|
||||||
|
|
||||||
|
|
||||||
Assert.IsTrue(await Dal.AddEmailMessageAsync(emailMessage));
|
Assert.IsTrue(await Dal.AddEmailMessageAsync(emailMessage));
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
using System.Security.Cryptography.X509Certificates;
|
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 Microsoft.Extensions.DependencyInjection;
|
|
||||||
using TIAM.Core;
|
using TIAM.Core;
|
||||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
//using TIAM.Database.DataLayers.ServiceProviders;
|
||||||
using TIAM.Database.DbContexts.Admins;
|
using TIAM.Database.DbContexts.Admins;
|
||||||
|
|
@ -16,7 +14,6 @@ using TIAM.Entities.Emails;
|
||||||
using TIAM.Entities.Permissions;
|
using TIAM.Entities.Permissions;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
using TIAM.Entities.ServiceProviders;
|
using TIAM.Entities.ServiceProviders;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
using TIAM.Entities.Transfers;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
using TIAM.Models.Dtos.Products;
|
using TIAM.Models.Dtos.Products;
|
||||||
|
|
@ -37,17 +34,17 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
public Transfer? GetTransferById(Guid transferId, bool autoInclude = false) => Session(ctx => ctx.GetTransferById(transferId, autoInclude));
|
public Transfer? GetTransferById(Guid transferId, bool autoInclude = false) => Session(ctx => ctx.GetTransferById(transferId, autoInclude));
|
||||||
public string? GetTransferJsonById(Guid transferId, bool autoInclude = false) => Session(ctx => ctx.GetTransferById(transferId, autoInclude)?.ToJson());
|
public string? GetTransferJsonById(Guid transferId, bool autoInclude = false) => Session(ctx => ctx.GetTransferById(transferId, autoInclude)?.ToJson());
|
||||||
|
|
||||||
public Task<bool> AddTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.AddTransfer(transfer) && ctx.SaveChanges() > 0);
|
public Task<bool> AddTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.AddTransfer(transfer));
|
||||||
public Task<bool> UpdateTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.UpdateTransfer(transfer) && ctx.SaveChanges() > 0);
|
public Task<bool> UpdateTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.UpdateTransfer(transfer));
|
||||||
public Task<bool> RemoveTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.RemoveTransfer(transfer) && ctx.SaveChanges() > 0);
|
public Task<bool> RemoveTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.RemoveTransfer(transfer));
|
||||||
public Task<bool> RemoveTransferAsync(Guid transferId) => TransactionAsync(ctx => ctx.RemoveTransfer(transferId) && ctx.SaveChanges() > 0);
|
public Task<bool> RemoveTransferAsync(Guid transferId) => TransactionAsync(ctx => ctx.RemoveTransfer(transferId));
|
||||||
#endregion Transfer
|
#endregion Transfer
|
||||||
|
|
||||||
#region TransferDestination
|
#region TransferDestination
|
||||||
public Task<bool> AddTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.AddTransferDestination(transferDestination) && ctx.SaveChanges() > 0);
|
public Task<bool> AddTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.AddTransferDestination(transferDestination));
|
||||||
public Task<bool> UpdateTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.UpdateTransferDestination(transferDestination) && ctx.SaveChanges() > 0);
|
public Task<bool> UpdateTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.UpdateTransferDestination(transferDestination));
|
||||||
public Task<bool> RemoveTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestination) && ctx.SaveChanges() > 0);
|
public Task<bool> RemoveTransferDestinationAsync(TransferDestination transferDestination, bool removeAddress = false) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestination, removeAddress));
|
||||||
public Task<bool> RemoveTransferDestinationAsync(Guid transferDestinationId) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestinationId) && ctx.SaveChanges() > 0);
|
public Task<bool> RemoveTransferDestinationAsync(Guid transferDestinationId, bool removeAddress = false) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestinationId, removeAddress));
|
||||||
|
|
||||||
#endregion TransferDestination
|
#endregion TransferDestination
|
||||||
|
|
||||||
|
|
@ -66,10 +63,10 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson());
|
public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson());
|
||||||
public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToList());
|
public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToList());
|
||||||
public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToJson());
|
public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToJson());
|
||||||
public Task<bool> AddProduct(Product product) => TransactionAsync(ctx => ctx.AddProduct(product) && ctx.SaveChanges() > 0);
|
public Task<bool> AddProduct(Product product) => TransactionAsync(ctx => ctx.AddProduct(product));
|
||||||
|
|
||||||
public Task<bool> UpdateProduct(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(product) && ctx.SaveChanges() > 0);
|
public Task<bool> UpdateProduct(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(product));
|
||||||
public Task<bool> RemoveProduct(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product) && ctx.SaveChanges() > 0);
|
public Task<bool> RemoveProduct(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product));
|
||||||
|
|
||||||
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
|
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
|
||||||
public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
|
public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
|
||||||
|
|
@ -88,7 +85,7 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
|
|
||||||
#region UserProductMapping
|
#region UserProductMapping
|
||||||
public Task<bool> AddUserProductMappingAsync(UserProductMapping userProductMapping)
|
public Task<bool> AddUserProductMappingAsync(UserProductMapping userProductMapping)
|
||||||
=> TransactionAsync(ctx => ctx.AddUserProductMapping(userProductMapping) && ctx.SaveChanges() > 0);
|
=> TransactionAsync(ctx => ctx.AddUserProductMapping(userProductMapping));
|
||||||
|
|
||||||
public async Task<UserProductMapping?> AddUserProductMappingAsync(Guid userProductMappingId, Guid userId, Guid productId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
|
public async Task<UserProductMapping?> AddUserProductMappingAsync(Guid userProductMappingId, Guid userId, Guid productId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
|
||||||
{
|
{
|
||||||
|
|
@ -98,14 +95,14 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
{
|
{
|
||||||
userProductMapping = ctx.AddUserProductMapping(userProductMappingId, userId, productId, permissions, userProductToCars);
|
userProductMapping = ctx.AddUserProductMapping(userProductMappingId, userId, productId, permissions, userProductToCars);
|
||||||
|
|
||||||
return userProductMapping != null && ctx.SaveChanges() > 0;
|
return userProductMapping != null;
|
||||||
});
|
});
|
||||||
|
|
||||||
return isSucces ? userProductMapping : null;
|
return isSucces ? userProductMapping : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<bool> UpdateUserProductMappingAsync(UserProductMapping userProductMapping)
|
public Task<bool> UpdateUserProductMappingAsync(UserProductMapping userProductMapping)
|
||||||
=> TransactionAsync(ctx => ctx.UpdateUserProductMapping(userProductMapping) && ctx.SaveChanges() > 0);
|
=> TransactionAsync(ctx => ctx.UpdateUserProductMapping(userProductMapping));
|
||||||
|
|
||||||
public async Task<UserProductMapping?> UpdateUserProductMappingAsync(Guid userProductMappingId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
|
public async Task<UserProductMapping?> UpdateUserProductMappingAsync(Guid userProductMappingId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
|
||||||
{
|
{
|
||||||
|
|
@ -115,17 +112,17 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
{
|
{
|
||||||
userProductMapping = ctx.UpdateUserProductMapping(userProductMappingId, permissions, userProductToCars);
|
userProductMapping = ctx.UpdateUserProductMapping(userProductMappingId, permissions, userProductToCars);
|
||||||
|
|
||||||
return userProductMapping != null && ctx.SaveChanges() > 0;
|
return userProductMapping != null;
|
||||||
});
|
});
|
||||||
|
|
||||||
return isSucces ? userProductMapping : null;
|
return isSucces ? userProductMapping : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<bool> RemoveUserProductMappingAsync(Guid userProductMappingId)
|
public Task<bool> RemoveUserProductMappingAsync(Guid userProductMappingId)
|
||||||
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userProductMappingId) && ctx.SaveChanges() > 0);
|
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userProductMappingId));
|
||||||
|
|
||||||
public Task<bool> RemoveUserProductMappingAsync(Guid userId, Guid productId)
|
public Task<bool> RemoveUserProductMappingAsync(Guid userId, Guid productId)
|
||||||
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userId, productId) && ctx.SaveChanges() > 0);
|
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userId, productId));
|
||||||
|
|
||||||
#endregion UserProductMapping
|
#endregion UserProductMapping
|
||||||
|
|
||||||
|
|
@ -139,13 +136,13 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
|
|
||||||
|
|
||||||
public Task<bool> AddEmailMessageAsync(EmailMessage emailMessage)
|
public Task<bool> AddEmailMessageAsync(EmailMessage emailMessage)
|
||||||
=> TransactionAsync(ctx => ctx.AddEmailMessage(emailMessage) && ctx.SaveChanges() > 0);
|
=> TransactionAsync(ctx => ctx.AddEmailMessage(emailMessage));
|
||||||
|
|
||||||
public Task<bool> UpdateEmailMessageAsync(EmailMessage emailMessage)
|
public Task<bool> UpdateEmailMessageAsync(EmailMessage emailMessage)
|
||||||
=> TransactionAsync(ctx => ctx.UpdateEmailMessage(emailMessage) && ctx.SaveChanges() > 0);
|
=> TransactionAsync(ctx => ctx.UpdateEmailMessage(emailMessage));
|
||||||
|
|
||||||
public Task<bool> RemoveEmailMessageAsync(Guid emailMessageId)
|
public Task<bool> RemoveEmailMessageAsync(Guid emailMessageId)
|
||||||
=> TransactionAsync(ctx => ctx.RemoveEmailMessage(emailMessageId) && ctx.SaveChanges() > 0);
|
=> TransactionAsync(ctx => ctx.RemoveEmailMessage(emailMessageId));
|
||||||
|
|
||||||
#endregion EmailMessage
|
#endregion EmailMessage
|
||||||
|
|
||||||
|
|
@ -327,26 +324,26 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
{
|
{
|
||||||
List<AssignedPermissionModel> result = new List<AssignedPermissionModel>();
|
List<AssignedPermissionModel> result = new List<AssignedPermissionModel>();
|
||||||
|
|
||||||
var UserProductMappings = Context.UserProductMappings.Where(x => x.ProductId == contextId).ToListAsync();
|
var userProductMappings = Context.UserProductMappings.Where(x => x.ProductId == contextId).ToList();
|
||||||
|
|
||||||
if (UserProductMappings.Result != null)
|
//if (userProductMappings.Result != null)
|
||||||
{
|
{
|
||||||
foreach (var item in UserProductMappings.Result)
|
foreach (var item in userProductMappings)
|
||||||
{
|
{
|
||||||
var mappingRow = Context.PermissionContextMappings.Where(x => x.SubjectId == item.Id).ToListAsync();
|
var mappingRows = Context.PermissionContextMappings.Where(x => x.SubjectId == item.Id).ToList();
|
||||||
if (mappingRow.Result == null)
|
if (mappingRows.Count == 0)
|
||||||
{
|
{
|
||||||
//user has no permission but is assigned... must be banned
|
//user has no permission but is assigned... must be banned
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (mappingRow.Result.Count > 1)
|
else if (mappingRows.Count > 1)
|
||||||
{
|
{
|
||||||
//user has been assigned more than onece to same context
|
//user has been assigned more than onece to same context
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var mapping in mappingRow.Result)
|
foreach (var mapping in mappingRows)
|
||||||
{
|
{
|
||||||
result.Add(new AssignedPermissionModel(item.ProductId, item.Id, mapping.SubjectType, item.UserId.ToString(), mapping.Permissions));
|
result.Add(new AssignedPermissionModel(item.ProductId, item.Id, mapping.SubjectType, item.UserId.ToString(), mapping.Permissions));
|
||||||
}
|
}
|
||||||
|
|
@ -355,26 +352,26 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var AssingedGroups = Context.PermissionGroups.Where(x => x.OwnerId == contextId).ToListAsync();
|
var assingedGroups = Context.PermissionGroups.Where(x => x.OwnerId == contextId).ToList();
|
||||||
|
|
||||||
if (AssingedGroups.Result != null)
|
//if (assingedGroups.Result != null)
|
||||||
{
|
{
|
||||||
foreach (var group in AssingedGroups.Result)
|
foreach (var group in assingedGroups)
|
||||||
{
|
{
|
||||||
var mappingRow = Context.PermissionContextMappings.Where(x => x.SubjectId == group.Id).ToListAsync();
|
var mappingRows = Context.PermissionContextMappings.Where(x => x.SubjectId == group.Id).ToList();
|
||||||
if (mappingRow.Result == null)
|
if (mappingRows.Count == 0)
|
||||||
{
|
{
|
||||||
//group has no permission but is assigned...
|
//group has no permission but is assigned...
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (mappingRow.Result.Count > 1)
|
else if (mappingRows.Count > 1)
|
||||||
{
|
{
|
||||||
//group has been assigned more than onece to same context
|
//group has been assigned more than onece to same context
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var mapping in mappingRow.Result)
|
foreach (var mapping in mappingRows)
|
||||||
{
|
{
|
||||||
result.Add(new AssignedPermissionModel(group.OwnerId, group.Id, mapping.SubjectType, group.GroupName, mapping.Permissions));
|
result.Add(new AssignedPermissionModel(group.OwnerId, group.Id, mapping.SubjectType, group.GroupName, mapping.Permissions));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ using TIAM.Database.DbSets.Users;
|
||||||
using AyCode.Database.DataLayers;
|
using AyCode.Database.DataLayers;
|
||||||
using AyCode.Database.DbSets.Users;
|
using AyCode.Database.DbSets.Users;
|
||||||
using TIAM.Database.DbSets.Products;
|
using TIAM.Database.DbSets.Products;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
using TIAM.Models.Dtos.Users;
|
using TIAM.Models.Dtos.Users;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using AyCode.Utils.Extensions;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Identity.Client;
|
using Microsoft.Identity.Client;
|
||||||
using TIAM.Database.DbContexts.Transfers;
|
using TIAM.Database.DbContexts.Transfers;
|
||||||
using TIAM.Entities.TransferDestinations;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
|
|
||||||
namespace TIAM.Database.DataLayers.TransferDestinations;
|
namespace TIAM.Database.DataLayers.TransferDestinations;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ using TIAM.Entities.Permissions;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
using TIAM.Entities.Profiles;
|
using TIAM.Entities.Profiles;
|
||||||
using TIAM.Entities.ServiceProviders;
|
using TIAM.Entities.ServiceProviders;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
using TIAM.Entities.Transfers;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
||||||
using AyCode.Database.DbContexts;
|
using AyCode.Database.DbContexts;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using TIAM.Entities.Auctions;
|
using TIAM.Entities.Auctions;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
|
|
||||||
namespace TIAM.Database.DbContexts.Auctions
|
namespace TIAM.Database.DbContexts.Auctions
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ using TIAM.Entities.Addresses;
|
||||||
using TIAM.Entities.Permissions;
|
using TIAM.Entities.Permissions;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
using TIAM.Entities.ServiceProviders;
|
using TIAM.Entities.ServiceProviders;
|
||||||
using TIAM.Entities.TransferDestinations;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
|
|
||||||
namespace TIAM.Database.DbContexts.ServiceProviders
|
namespace TIAM.Database.DbContexts.ServiceProviders
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using TIAM.Entities.TransferDestinations;
|
using TIAM.Entities.Transfers;
|
||||||
|
|
||||||
namespace TIAM.Database.DbContexts.Transfers
|
namespace TIAM.Database.DbContexts.Transfers
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ using TIAM.Entities.Emails;
|
||||||
using TIAM.Entities.Permissions;
|
using TIAM.Entities.Permissions;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
using TIAM.Entities.Profiles;
|
using TIAM.Entities.Profiles;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
using TIAM.Entities.Transfers;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public static class EmailMessageDbSetExtension
|
||||||
=> ctx.EmailMessages.Where(x => x.SenderId == senderId);
|
=> ctx.EmailMessages.Where(x => x.SenderId == senderId);
|
||||||
|
|
||||||
public static IQueryable<EmailMessage> GetEmailMessagesBySenderEmailAddress(this IEmailMessageDbSet ctx, string senderEmailAddress)
|
public static IQueryable<EmailMessage> GetEmailMessagesBySenderEmailAddress(this IEmailMessageDbSet ctx, string senderEmailAddress)
|
||||||
=> ctx.EmailMessages.Where(x => x.SenderEmailAddress == senderEmailAddress);
|
=> ctx.EmailMessages.Where(x => x.EmailAddress == senderEmailAddress);
|
||||||
|
|
||||||
private static IQueryable<EmailMessage> GetEmailMessages(this IQueryable<EmailMessage> queryableEmails, Guid userId, Guid userProductMappingId)
|
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));
|
=> queryableEmails.Where(x => x.SenderId == userId || x.SenderId == userProductMappingId || x.Recipients.Any(recipient => recipient.RecipientId == userId || recipient.RecipientId == userProductMappingId));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
using TIAM.Entities.Transfers;
|
using TIAM.Entities.Transfers;
|
||||||
|
|
||||||
namespace TIAM.Database.DbSets.Transfers;
|
namespace TIAM.Database.DbSets.Transfers;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using TIAM.Entities.Addresses;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
using TIAM.Entities.TransferDestinations;
|
using TIAM.Entities.Transfers;
|
||||||
|
|
||||||
namespace TIAM.Database.DbSets.Transfers;
|
namespace TIAM.Database.DbSets.Transfers;
|
||||||
|
|
||||||
public interface ITransferDestinationDbSet
|
public interface ITransferDestinationDbSet
|
||||||
{
|
{
|
||||||
public DbSet<TransferDestination> TransferDestinations { get; set; }
|
public DbSet<TransferDestination> TransferDestinations { get; set; }
|
||||||
|
public DbSet<Address> Addresses { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using TIAM.Database.DbSets.Products;
|
|
||||||
using TIAM.Database.DbSets.Users;
|
|
||||||
using TIAM.Entities.Products;
|
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
using TIAM.Entities.Transfers;
|
using TIAM.Entities.Transfers;
|
||||||
|
|
||||||
namespace TIAM.Database.DbSets.Transfers;
|
namespace TIAM.Database.DbSets.Transfers;
|
||||||
|
|
@ -47,13 +43,17 @@ public static class TransferDbSetExtensions
|
||||||
public static bool UpdateTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination)
|
public static bool UpdateTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination)
|
||||||
=> ctx.TransferDestinations.Update(transferDestination).State == EntityState.Modified;
|
=> ctx.TransferDestinations.Update(transferDestination).State == EntityState.Modified;
|
||||||
|
|
||||||
public static bool RemoveTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination)
|
public static bool RemoveTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination, bool removeAddress)
|
||||||
=> ctx.TransferDestinations.Remove(transferDestination).State == EntityState.Deleted;
|
|
||||||
|
|
||||||
public static bool RemoveTransferDestination(this ITransferDestinationDbSet ctx, Guid transferDestinationId)
|
|
||||||
{
|
{
|
||||||
var transfer = ctx.GetTransferDestinationById(transferDestinationId);
|
if (removeAddress) ctx.Addresses.Remove(transferDestination.Address);
|
||||||
return transfer == null || ctx.RemoveTransferDestination(transferDestinationId);
|
|
||||||
|
return ctx.TransferDestinations.Remove(transferDestination).State == EntityState.Deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool RemoveTransferDestination(this ITransferDestinationDbSet ctx, Guid transferDestinationId, bool removeAddress)
|
||||||
|
{
|
||||||
|
var transferDestination = ctx.GetTransferDestinationById(transferDestinationId);
|
||||||
|
return transferDestination == null || ctx.RemoveTransferDestination(transferDestination, removeAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion TransferDestination
|
#endregion TransferDestination
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,25 @@ using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using AyCode.Interfaces.Entities;
|
using AyCode.Interfaces.Entities;
|
||||||
using AyCode.Interfaces.TimeStampInfo;
|
using AyCode.Interfaces.TimeStampInfo;
|
||||||
|
using AyCode.Interfaces.Users;
|
||||||
|
|
||||||
namespace TIAM.Entities.Emails;
|
namespace TIAM.Entities.Emails;
|
||||||
|
|
||||||
[Table(nameof(EmailMessage))]
|
[Table(nameof(EmailMessage))]
|
||||||
public class EmailMessage : IEntityGuid, ITimeStampInfo, IEmailRecipientsRelation
|
public class EmailMessage : IEntityGuid, ITimeStampInfo, IEmailRecipientsRelation, IEmailAddress
|
||||||
{
|
{
|
||||||
public EmailMessage()
|
public EmailMessage()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmailMessage(Guid id, Guid? senderId, Guid contextId, string subject, string? text, string senderEmailAddress) : this()
|
public EmailMessage(Guid id, Guid? senderId, Guid contextId, string subject, string? text, string emailAddress) : this()
|
||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
SenderId = senderId;
|
SenderId = senderId;
|
||||||
ContextId = contextId;
|
ContextId = contextId;
|
||||||
Subject = subject;
|
Subject = subject;
|
||||||
Text = text;
|
Text = text;
|
||||||
SenderEmailAddress = senderEmailAddress;
|
EmailAddress = emailAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||||
|
|
@ -32,7 +33,7 @@ public class EmailMessage : IEntityGuid, ITimeStampInfo, IEmailRecipientsRelatio
|
||||||
public virtual List<EmailRecipient> Recipients { get; set; } = [];
|
public virtual List<EmailRecipient> Recipients { get; set; } = [];
|
||||||
|
|
||||||
[MaxLength(150)]
|
[MaxLength(150)]
|
||||||
public string SenderEmailAddress { get; set; }
|
public string EmailAddress { get; set; }
|
||||||
[MaxLength(100)]
|
[MaxLength(100)]
|
||||||
public string Subject { get; set; }
|
public string Subject { get; set; }
|
||||||
public string? Text { get; set; }
|
public string? Text { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,23 @@
|
||||||
using AyCode.Interfaces.TimeStampInfo;
|
using AyCode.Interfaces.TimeStampInfo;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using AyCode.Interfaces.Users;
|
||||||
|
|
||||||
namespace TIAM.Entities.Emails;
|
namespace TIAM.Entities.Emails;
|
||||||
|
|
||||||
//Update efcore, aspnetcore to 8.0.1; Implement EmailMessage, EmailRecipient; refactoring, improvments, fixes, etc...
|
//Update efcore, aspnetcore to 8.0.1; Implement EmailMessage, EmailRecipient; refactoring, improvments, fixes, etc...
|
||||||
public class EmailRecipient : IEntityGuid, ITimeStampInfo, IEmailMessageRelation
|
public class EmailRecipient : IEntityGuid, ITimeStampInfo, IEmailMessageRelation, IEmailAddress
|
||||||
{
|
{
|
||||||
public EmailRecipient()
|
public EmailRecipient()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmailRecipient(Guid id, Guid recipientId, Guid emailMessageId) : this()
|
public EmailRecipient(Guid id, Guid recipientId, Guid emailMessageId, string emailAddress) : this()
|
||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
RecipientId = recipientId;
|
RecipientId = recipientId;
|
||||||
EmailMessageId = emailMessageId;
|
EmailMessageId = emailMessageId;
|
||||||
|
EmailAddress = emailAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||||
|
|
@ -24,6 +26,9 @@ public class EmailRecipient : IEntityGuid, ITimeStampInfo, IEmailMessageRelation
|
||||||
|
|
||||||
public Guid RecipientId { get; set; }
|
public Guid RecipientId { get; set; }
|
||||||
public Guid EmailMessageId { get; set; }
|
public Guid EmailMessageId { get; set; }
|
||||||
|
public string EmailAddress { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public virtual EmailMessage EmailMessage { get; set; }
|
public virtual EmailMessage EmailMessage { get; set; }
|
||||||
|
|
||||||
public DateTime Created { get; set; }
|
public DateTime Created { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using AyCode.Interfaces.Entities;
|
using AyCode.Interfaces.Entities;
|
||||||
using AyCode.Entities.Locations;
|
|
||||||
using AyCode.Interfaces.TimeStampInfo;
|
using AyCode.Interfaces.TimeStampInfo;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using TIAM.Core.Enums;
|
using TIAM.Core.Enums;
|
||||||
using TIAM.Entities.Addresses;
|
using TIAM.Entities.Addresses;
|
||||||
|
|
||||||
namespace TIAM.Entities.TransferDestinations
|
namespace TIAM.Entities.Transfers
|
||||||
{
|
{
|
||||||
[Table("TransferDestination")]
|
[Table("TransferDestination")]
|
||||||
public class TransferDestination : IEntityGuid, ITimeStampInfo //LocationBase
|
public class TransferDestination : IEntityGuid, ITimeStampInfo //LocationBase
|
||||||
|
|
@ -23,11 +21,13 @@ namespace TIAM.Entities.TransferDestinations
|
||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
public double Price { get; set; }
|
|
||||||
public PriceType PriceType { get; set; }
|
public PriceType PriceType { get; set; }
|
||||||
|
public double Price { get; set; }
|
||||||
|
public double Price2 { get; set; }
|
||||||
|
public double Price3 { get; set; }
|
||||||
|
|
||||||
//TEMPORARY!!!
|
//TEMPORARY!!!
|
||||||
public string AddressString { get; set; }
|
public string? AddressString { get; set; }
|
||||||
|
|
||||||
public DateTime Created { get; set; }
|
public DateTime Created { get; set; }
|
||||||
public DateTime Modified { get; set; }
|
public DateTime Modified { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using TIAM.Entities.TransferDestinations;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAMWebApp.Shared.Application.Interfaces;
|
using TIAMWebApp.Shared.Application.Interfaces;
|
||||||
using TIAMWebApp.Shared.Application.Models;
|
using TIAMWebApp.Shared.Application.Models;
|
||||||
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,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.Entities.TransferDestinations;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAMWebApp.Shared.Application.Interfaces;
|
using TIAMWebApp.Shared.Application.Interfaces;
|
||||||
using TIAMWebApp.Shared.Application.Models;
|
using TIAMWebApp.Shared.Application.Models;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Components.Forms;
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
using TIAMWebApp.Shared.Application.Utility;
|
using TIAMWebApp.Shared.Application.Utility;
|
||||||
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
||||||
using TIAMWebApp.Shared.Application.Models.PageModels;
|
using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
@using System.IdentityModel.Tokens.Jwt;
|
@using System.IdentityModel.Tokens.Jwt;
|
||||||
@using TIAMSharedUI.Pages.Components;
|
@using TIAMSharedUI.Pages.Components;
|
||||||
@using TIAMSharedUI.Shared
|
@using TIAMSharedUI.Shared
|
||||||
@using TIAM.Entities.TransferDestinations
|
|
||||||
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||||
@inject NavigationManager NavManager
|
@inject NavigationManager NavManager
|
||||||
@inject IUserDataService UserDataService;
|
@inject IUserDataService UserDataService;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
@using TIAMWebApp.Shared.Application.Interfaces
|
@using TIAMWebApp.Shared.Application.Interfaces
|
||||||
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||||
@using TIAMWebApp.Shared.Application.Utility
|
@using TIAMWebApp.Shared.Application.Utility
|
||||||
@using TIAM.Entities.TransferDestinations
|
@using TIAM.Entities.Transfers
|
||||||
@inject LogToBrowserConsole logToBrowserConsole
|
@inject LogToBrowserConsole logToBrowserConsole
|
||||||
@inject IWizardProcessor WizardProcessor
|
@inject IWizardProcessor WizardProcessor
|
||||||
<h3>TestPage</h3>
|
<h3>TestPage</h3>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
@page "/transfer"
|
@page "/transfer"
|
||||||
@using TIAM.Entities.TransferDestinations
|
|
||||||
@using TIAMSharedUI.Pages.Components
|
@using TIAMSharedUI.Pages.Components
|
||||||
@using TIAMSharedUI.Shared
|
@using TIAMSharedUI.Shared
|
||||||
@using TIAMWebApp.Shared.Application.Interfaces
|
@using TIAMWebApp.Shared.Application.Interfaces
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
||||||
using TIAMWebApp.Shared.Application.Models;
|
using TIAMWebApp.Shared.Application.Models;
|
||||||
using TIAMWebApp.Shared.Application.Interfaces;
|
using TIAMWebApp.Shared.Application.Interfaces;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
|
|
||||||
namespace TIAMSharedUI.Pages.User.SysAdmins
|
namespace TIAMSharedUI.Pages.User.SysAdmins
|
||||||
{
|
{
|
||||||
|
|
@ -105,7 +104,7 @@ namespace TIAMSharedUI.Pages.User.SysAdmins
|
||||||
//add new orderData to orderData array
|
//add new orderData to orderData array
|
||||||
|
|
||||||
//await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel);
|
//await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel);
|
||||||
await transferDataService.CreateTransferDestination(TransferDestinationWizardModel.SaveToTransferDestination(myModel));
|
await transferDataService.CreateTransferDestination(TransferDestinationWizardModel.CopyToTransferDestination(myModel));
|
||||||
//await transferDataService.CreateTransferDestination(new TransferDestination
|
//await transferDataService.CreateTransferDestination(new TransferDestination
|
||||||
/*{
|
/*{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
|
|
@ -142,7 +141,7 @@ namespace TIAMSharedUI.Pages.User.SysAdmins
|
||||||
transferToModify.Price = myModel.Price;
|
transferToModify.Price = myModel.Price;
|
||||||
transferToModify.PriceType = myModel.PriceType;
|
transferToModify.PriceType = myModel.PriceType;
|
||||||
|
|
||||||
await transferDataService.UpdateTransferDestination(TransferDestinationWizardModel.SaveToTransferDestination(transferToModify));
|
await transferDataService.UpdateTransferDestination(TransferDestinationWizardModel.CopyToTransferDestination(transferToModify));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,7 +176,7 @@ namespace TIAMSharedUI.Pages.User.SysAdmins
|
||||||
{
|
{
|
||||||
//add new transferwizardmodel to transferData array
|
//add new transferwizardmodel to transferData array
|
||||||
TransferDataFromDb = ((TransferDestinationWizardModel[])TransferDataFromDb).Append(
|
TransferDataFromDb = ((TransferDestinationWizardModel[])TransferDataFromDb).Append(
|
||||||
new TransferDestinationWizardModel(item.Id, item.Name, item.Description, item.AddressString, item.Price, item.PriceType)).ToArray();
|
new TransferDestinationWizardModel(item.Id, item.Name, item.Description, item.AddressString, item.Price, item.PriceType, item.Address)).ToArray();
|
||||||
logToBrowserConsole.LogToBC($"TransferDataFromDb: {item.Name}");
|
logToBrowserConsole.LogToBC($"TransferDataFromDb: {item.Name}");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
@using System.Linq.Expressions
|
@using System.Linq.Expressions
|
||||||
|
@using TIAM.Entities.Transfers
|
||||||
@using TIAMWebApp.Shared.Application.Interfaces
|
@using TIAMWebApp.Shared.Application.Interfaces
|
||||||
@using TIAMWebApp.Shared.Application.Utility
|
@using TIAMWebApp.Shared.Application.Utility
|
||||||
@using TIAM.Entities.TransferDestinations
|
|
||||||
@inject LogToBrowserConsole logToBrowserConsole
|
@inject LogToBrowserConsole logToBrowserConsole
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ using System.Net.Http.Json;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using TIAM.Entities.Permissions;
|
using TIAM.Entities.Permissions;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
using TIAM.Models.Dtos.Products;
|
using TIAM.Models.Dtos.Products;
|
||||||
using TIAMWebApp.Shared.Application.Interfaces;
|
using TIAMWebApp.Shared.Application.Interfaces;
|
||||||
using TIAMWebApp.Shared.Application.Models;
|
using TIAMWebApp.Shared.Application.Models;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ using Microsoft.JSInterop;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using TIAM.Entities.TransferDestinations;
|
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
using TIAMWebApp.Shared.Application.Interfaces;
|
using TIAMWebApp.Shared.Application.Interfaces;
|
||||||
using TIAMWebApp.Shared.Application.Models;
|
using TIAMWebApp.Shared.Application.Models;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ using TIAM.Database.DataLayers.Admins;
|
||||||
using TIAM.Database.DataLayers.TransferDestinations;
|
using TIAM.Database.DataLayers.TransferDestinations;
|
||||||
using TIAM.Database.DataLayers.Users;
|
using TIAM.Database.DataLayers.Users;
|
||||||
using TIAM.Database.DbContexts;
|
using TIAM.Database.DbContexts;
|
||||||
using TIAM.Entities.TransferDestinations;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
using TIAMWebApp.Shared.Application.Models;
|
using TIAMWebApp.Shared.Application.Models;
|
||||||
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
||||||
|
|
@ -74,16 +74,16 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route(APIUrls.CreateTransferDestinationRouteName)]
|
[Route(APIUrls.CreateTransferDestinationRouteName)]
|
||||||
public async Task<IActionResult> CreateTransferDestination([FromBody] JsonElement SerializedTransferDestinationModel)
|
public async Task<IActionResult> CreateTransferDestination([FromBody] JsonElement serializedTransferDestinationModel)
|
||||||
{
|
{
|
||||||
Console.WriteLine("CreateTransferDestination called!");
|
Console.WriteLine("CreateTransferDestination called!");
|
||||||
if (string.IsNullOrEmpty(SerializedTransferDestinationModel.GetRawText()))
|
if (string.IsNullOrEmpty(serializedTransferDestinationModel.GetRawText()))
|
||||||
{
|
{
|
||||||
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TransferDestination? transferDestination = JObject.Parse(SerializedTransferDestinationModel.GetRawText()).ToObject<TransferDestination>();
|
TransferDestination? transferDestination = JObject.Parse(serializedTransferDestinationModel.GetRawText()).ToObject<TransferDestination>();
|
||||||
|
|
||||||
if (transferDestination != null)
|
if (transferDestination != null)
|
||||||
{
|
{
|
||||||
|
|
@ -102,6 +102,8 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
Console.WriteLine($"TransferDestination to be created: {transferDestination.AddressId}");
|
Console.WriteLine($"TransferDestination to be created: {transferDestination.AddressId}");
|
||||||
Console.WriteLine($"TransferDestination to be created: {transferDestination.Name}");
|
Console.WriteLine($"TransferDestination to be created: {transferDestination.Name}");
|
||||||
Console.WriteLine($"TransferDestination to be created: {transferDestination.Price}");
|
Console.WriteLine($"TransferDestination to be created: {transferDestination.Price}");
|
||||||
|
Console.WriteLine($"TransferDestination to be created: {transferDestination.Price2}");
|
||||||
|
Console.WriteLine($"TransferDestination to be created: {transferDestination.Price3}");
|
||||||
Console.WriteLine($"TransferDestination to be created: {transferDestination.PriceType}");
|
Console.WriteLine($"TransferDestination to be created: {transferDestination.PriceType}");
|
||||||
Console.WriteLine($"TransferDestination to be created: {transferDestination.AddressString}");
|
Console.WriteLine($"TransferDestination to be created: {transferDestination.AddressString}");
|
||||||
Console.WriteLine($"TransferDestination to be created: {transferDestination.Description}");
|
Console.WriteLine($"TransferDestination to be created: {transferDestination.Description}");
|
||||||
|
|
@ -125,10 +127,10 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route(APIUrls.UpdateTransferDestinationRouteName)]
|
[Route(APIUrls.UpdateTransferDestinationRouteName)]
|
||||||
public async Task<IActionResult> UpdateTransferDestination([FromBody]JsonElement SerializedTransferDestinationModel)
|
public async Task<IActionResult> UpdateTransferDestination([FromBody]JsonElement serializedTransferDestination)
|
||||||
{
|
{
|
||||||
Console.WriteLine("UpdateTransferDestination called!");
|
Console.WriteLine("UpdateTransferDestination called!");
|
||||||
if (string.IsNullOrEmpty(SerializedTransferDestinationModel.GetRawText()))
|
if (string.IsNullOrEmpty(serializedTransferDestination.GetRawText()))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Bad request!");
|
Console.WriteLine("Bad request!");
|
||||||
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
||||||
|
|
@ -136,8 +138,8 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("Serialized model not empty!");
|
Console.WriteLine("Serialized model not empty!");
|
||||||
TransferDestination? transferDestination = JObject.Parse(SerializedTransferDestinationModel.GetRawText()).ToObject<TransferDestination>();
|
TransferDestination? transferDestination = JObject.Parse(serializedTransferDestination.GetRawText()).ToObject<TransferDestination>();
|
||||||
Console.WriteLine($"TransferDestination to be updated: {SerializedTransferDestinationModel.GetRawText()}");
|
Console.WriteLine($"TransferDestination to be updated: {serializedTransferDestination.GetRawText()}");
|
||||||
Console.WriteLine($"TransferDestination to be updated: {transferDestination.AddressString}");
|
Console.WriteLine($"TransferDestination to be updated: {transferDestination.AddressString}");
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -158,31 +160,33 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
Console.WriteLine($"TransferDestination to be updated: {transferDestination.Id}");
|
Console.WriteLine($"TransferDestination to be updated: {transferDestination.Id}");
|
||||||
Console.WriteLine($"TransferDestination to be updated new name: {transferDestination.Name}");
|
Console.WriteLine($"TransferDestination to be updated new name: {transferDestination.Name}");
|
||||||
Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price}");
|
Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price}");
|
||||||
|
Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price2}");
|
||||||
|
Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price3}");
|
||||||
Console.WriteLine($"TransferDestination to be updated new priceType: {transferDestination.PriceType}");
|
Console.WriteLine($"TransferDestination to be updated new priceType: {transferDestination.PriceType}");
|
||||||
Console.WriteLine($"TransferDestination to be updated new address: {transferDestination.AddressString}");
|
Console.WriteLine($"TransferDestination to be updated new address: {transferDestination.AddressString}");
|
||||||
Console.WriteLine($"TransferDestination to be updated new description: {transferDestination.Description}");
|
Console.WriteLine($"TransferDestination to be updated new description: {transferDestination.Description}");
|
||||||
|
|
||||||
var dbTransferDestinationJson = _adminDal.GetTransferDestinationJsonById(transferDestination.Id);
|
//var dbTransferDestinationJson = _adminDal.GetTransferDestinationJsonById(transferDestination.Id);
|
||||||
Console.WriteLine($"TransferDestination JSON to be updated: {dbTransferDestinationJson}");
|
//Console.WriteLine($"TransferDestination JSON to be updated: {dbTransferDestinationJson}");
|
||||||
|
|
||||||
var dbTransferDestination = JObject.Parse(dbTransferDestinationJson).ToObject<TransferDestination>();
|
//var dbTransferDestination = JObject.Parse(dbTransferDestinationJson).ToObject<TransferDestination>();
|
||||||
if (dbTransferDestination.Id != Guid.Empty)
|
|
||||||
{
|
|
||||||
|
|
||||||
dbTransferDestination.AddressId = transferDestination.AddressId;
|
//var dbTransferDestination = _adminDal.GetTransferDestinationById(transferDestination.Id, true);
|
||||||
dbTransferDestination.Price = transferDestination.Price;
|
//if (dbTransferDestination.Id != Guid.Empty)
|
||||||
dbTransferDestination.PriceType = transferDestination.PriceType;
|
//{
|
||||||
dbTransferDestination.Name = transferDestination.Name;
|
// dbTransferDestination.AddressId = transferDestination.AddressId;
|
||||||
dbTransferDestination.Description = transferDestination.Description;
|
// dbTransferDestination.Price = transferDestination.Price;
|
||||||
dbTransferDestination.AddressString = transferDestination.AddressString;
|
// dbTransferDestination.PriceType = transferDestination.PriceType;
|
||||||
dbTransferDestination.Address = transferDestination.Address;
|
// dbTransferDestination.Name = transferDestination.Name;
|
||||||
|
// dbTransferDestination.Description = transferDestination.Description;
|
||||||
}
|
// dbTransferDestination.AddressString = transferDestination.AddressString;
|
||||||
|
// dbTransferDestination.Address = transferDestination.Address;
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
||||||
await _adminDal.UpdateTransferDestinationAsync(dbTransferDestination);
|
await _adminDal.UpdateTransferDestinationAsync(transferDestination);
|
||||||
return Ok(dbTransferDestination);
|
return Ok(transferDestination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using TIAM.Entities.TransferDestinations;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAMWebApp.Shared.Application.Models;
|
using TIAMWebApp.Shared.Application.Models;
|
||||||
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using TIAM.Core.Enums;
|
using TIAM.Core.Enums;
|
||||||
using TIAM.Entities.Addresses;
|
using TIAM.Entities.Addresses;
|
||||||
using TIAM.Entities.TransferDestinations;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAM.Resources;
|
using TIAM.Resources;
|
||||||
|
|
||||||
namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||||
|
|
@ -45,6 +45,8 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||||
|
|
||||||
public PriceType PriceType { get; set; }
|
public PriceType PriceType { get; set; }
|
||||||
|
|
||||||
|
public Address Address { get; set; }
|
||||||
|
|
||||||
//[DataType("Latitude")]
|
//[DataType("Latitude")]
|
||||||
//[Display(Name = "Destination latitude")]
|
//[Display(Name = "Destination latitude")]
|
||||||
//public double Latitude { get; set; }
|
//public double Latitude { get; set; }
|
||||||
|
|
@ -55,30 +57,34 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||||
|
|
||||||
public TransferDestinationWizardModel() { }
|
public TransferDestinationWizardModel() { }
|
||||||
|
|
||||||
public TransferDestinationWizardModel(string name, string description, string address, double price, PriceType priceType) :this(Guid.NewGuid(), name, description, address, price, priceType)
|
public TransferDestinationWizardModel(string name, string description, string addressString, double price, PriceType priceType, Address address) :this(Guid.NewGuid(), name, description, addressString, price, priceType, address)
|
||||||
{ }
|
{ }
|
||||||
public TransferDestinationWizardModel(Guid id, string name, string description, string address, double price, PriceType priceType)
|
public TransferDestinationWizardModel(Guid id, string name, string description, string addressString, double price, PriceType priceType, Address address)
|
||||||
{
|
{
|
||||||
|
|
||||||
Id = id.ToString();
|
Id = id.ToString();
|
||||||
Name = name;
|
Name = name;
|
||||||
Description = description;
|
Description = description;
|
||||||
AddressString = address;
|
AddressString = addressString;
|
||||||
Price = price;
|
Price = price;
|
||||||
PriceType = priceType;
|
PriceType = priceType;
|
||||||
|
Address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TransferDestination SaveToTransferDestination(TransferDestinationWizardModel model)
|
public static TransferDestination CopyToTransferDestination(TransferDestinationWizardModel model)
|
||||||
=> SaveToTransferDestination(model, new TransferDestination());
|
=> CopyToTransferDestination(model, new TransferDestination());
|
||||||
|
|
||||||
public static TransferDestination SaveToTransferDestination(TransferDestinationWizardModel model, TransferDestination destination)
|
public static TransferDestination CopyToTransferDestination(TransferDestinationWizardModel model, TransferDestination destination)
|
||||||
{
|
{
|
||||||
destination.Id = Guid.Parse(model.Id);
|
destination.Id = Guid.Parse(model.Id);
|
||||||
destination.Name = model.Name;
|
destination.Name = model.Name;
|
||||||
destination.Description = model.Description;
|
destination.Description = model.Description;
|
||||||
destination.AddressString = model.AddressString;
|
destination.AddressString = model.AddressString;
|
||||||
destination.Price = model.Price;
|
destination.Price = model.Price;
|
||||||
|
destination.Price2 = model.Price;
|
||||||
|
destination.Price3 = model.Price;
|
||||||
destination.PriceType = model.PriceType;
|
destination.PriceType = model.PriceType;
|
||||||
|
destination.Address = model.Address;
|
||||||
|
|
||||||
if (destination.Address == null)
|
if (destination.Address == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using TIAM.Entities.TransferDestinations;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAMWebApp.Shared.Application.Interfaces;
|
using TIAMWebApp.Shared.Application.Interfaces;
|
||||||
using TIAMWebApp.Shared.Application.Models;
|
using TIAMWebApp.Shared.Application.Models;
|
||||||
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue