Merge branch 'master' of http://git2.aycode.com/Adam/TourIAm
This commit is contained in:
commit
c29cc3fcc1
|
|
@ -12,6 +12,7 @@ using TIAM.Database.DbContexts.ServiceProviders;
|
|||
using TIAM.Database.DbSets.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
|
||||
namespace TIAM.Database.Test
|
||||
{
|
||||
|
|
@ -105,6 +106,37 @@ namespace TIAM.Database.Test
|
|||
Assert.IsNotNull(userProductMapping.Product, "Product is null");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
|
||||
[DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")]
|
||||
[DataRow("ac612aa8-863b-4b4f-9d63-f5d261b5c5f9")]
|
||||
public void SerializeUserModelDto_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
|
||||
{
|
||||
var userId = Guid.Parse(userIdString);
|
||||
|
||||
JsonSerializerSettings options = new()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
var userModel = Dal.GetUserModelDtoById(userId);
|
||||
|
||||
var serializedUserModel = JsonConvert.SerializeObject(userModel, options);
|
||||
userModel = JsonConvert.DeserializeObject<UserModelDto>(serializedUserModel);
|
||||
|
||||
Assert.IsNotNull(userModel);
|
||||
Assert.IsNotNull(userModel.UserDto);
|
||||
Assert.IsNotNull(userModel.Profile);
|
||||
|
||||
if (userId != Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00")) return; //csak az "540271F6.."-nek van product-ja! - J.
|
||||
|
||||
Assert.IsTrue(userModel.Products.Count > 0);
|
||||
Assert.IsTrue(userModel.UserProductMappings.Count > 0);
|
||||
|
||||
Assert.IsTrue(userModel.ServiceProviders.Count > 0);
|
||||
Assert.IsTrue(userModel.UserToServiceProviders.Count > 0);
|
||||
}
|
||||
//[TestMethod]
|
||||
//[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
|
||||
//public void SerializeUser_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Moq" Version="4.20.69" />
|
||||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0">
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@ using TIAM.Entities.Profiles;
|
|||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using AyCode.Interfaces.Users.Dtos;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
|
||||
namespace TIAM.Database.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, Profile, UserToken>
|
||||
public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider>
|
||||
{
|
||||
private Mock<UserDbContext> _mockContext;
|
||||
|
||||
|
|
@ -39,21 +40,38 @@ namespace TIAM.Database.Test
|
|||
|
||||
[TestMethod]
|
||||
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
|
||||
public override void GetUserById_ReturnsUser_WhenUserExists(string userIdString)
|
||||
=> base.GetUserById_ReturnsUser_WhenUserExists(userIdString);
|
||||
public void GetUserById_ReturnsUser_WhenUserAndRelationsExists(string userIdString)
|
||||
{
|
||||
var user = AcBase_GetUserById_ReturnsUser_WhenUserExists(userIdString);
|
||||
|
||||
Assert.IsTrue(user.ServiceProviders.Count > 0);
|
||||
Assert.IsTrue(user.UserToServiceProviders.Count > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("test@tiam.hu")]
|
||||
public void GetUserByEmail_ReturnsUser_WhenUserAndRelationsExists(string email)
|
||||
{
|
||||
var user = AcBase_GetUserByEmail_ReturnsUser_WhenUserExists(email);
|
||||
|
||||
Assert.IsTrue(user.ServiceProviders.Count > 0);
|
||||
Assert.IsTrue(user.UserToServiceProviders.Count > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("test@tiam.hu")]
|
||||
public override void GetUserByEmail_ReturnsUser_WhenUserExists(string email)
|
||||
=> base.GetUserByEmail_ReturnsUser_WhenUserExists(email);
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("test@tiam.hu")]
|
||||
public override Task GetUserByEmailAsync_ReturnsUser_WhenUserExists(string email)
|
||||
=> base.GetUserByEmailAsync_ReturnsUser_WhenUserExists(email);
|
||||
public async Task GetUserByEmailAsync_ReturnsUser_WhenUserAndRelationsExists(string email)
|
||||
{
|
||||
var user = await AcBase_GetUserByEmailAsync_ReturnsUser_WhenUserExists(email);
|
||||
|
||||
Assert.IsTrue(user.ServiceProviders.Count > 0);
|
||||
Assert.IsTrue(user.UserToServiceProviders.Count > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
|
||||
[DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")]
|
||||
[DataRow("ac612aa8-863b-4b4f-9d63-f5d261b5c5f9")]
|
||||
public async Task SerializeUserModelDto_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
|
||||
{
|
||||
var userId = Guid.Parse(userIdString);
|
||||
|
|
@ -72,9 +90,14 @@ namespace TIAM.Database.Test
|
|||
Assert.IsNotNull(userModel);
|
||||
Assert.IsNotNull(userModel.UserDto);
|
||||
Assert.IsNotNull(userModel.Profile);
|
||||
|
||||
|
||||
if (userId != Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00")) return; //csak az "540271F6.."-nek van product-ja! - J.
|
||||
|
||||
Assert.IsTrue(userModel.Products.Count > 0);
|
||||
Assert.IsTrue(userModel.UserProductMappings.Count > 0);
|
||||
|
||||
Assert.IsTrue(userModel.ServiceProviders.Count > 0);
|
||||
Assert.IsTrue(userModel.UserToServiceProviders.Count > 0);
|
||||
}
|
||||
|
||||
//[TestMethod]
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ namespace TIAM.Database.DataLayers.ServiceProviders
|
|||
public User? GetUserByEmail(string email, bool autoInclude = false) => Session(x => x.GetUserByEmail(email, autoInclude));
|
||||
|
||||
public UserModelDto? GetUserModelDtoById(Guid userId) => Session(x => x.GetUserModelDtoById(userId));
|
||||
public Task<UserModelDto?> GetUserModelDtoByIdAsync(Guid userId) => SessionAsync(x => x.GetUserModelDtoById(userId));
|
||||
public UserModelDto? GetUserModelDtoByEmail(string email) => Session(x => x.GetUserModelDtoByEmail(email));
|
||||
|
||||
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(x => x.GetUserProductMappingById(userProductMappingId, autoInclude));
|
||||
|
|
|
|||
|
|
@ -11,12 +11,13 @@ using Microsoft.EntityFrameworkCore;
|
|||
using TIAM.Database.DbContexts.Users;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
|
||||
namespace TIAM.Database.DataLayers.Users
|
||||
{
|
||||
public class UserDal : AcUserDalBase<UserDbContext, User, Profile, UserToken>
|
||||
public class UserDal : AcUserDalBase<UserDbContext, User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider>
|
||||
{
|
||||
|
||||
public UserDal() : base()
|
||||
|
|
@ -32,6 +33,7 @@ namespace TIAM.Database.DataLayers.Users
|
|||
return Context.Users.ToListAsync();
|
||||
}
|
||||
|
||||
public UserModelDto? GetUserModelDtoById(Guid userId) => Session(x => x.GetUserModelDtoById(userId));
|
||||
public Task<UserModelDto?> GetUserModelDtoByIdAsync(Guid userId) => SessionAsync(x => x.GetUserModelDtoById(userId));
|
||||
public Task<UserModelDto?> GetUserModelDtoByEmailAsync(string email) => SessionAsync(x => x.GetUserModelDtoByEmail(email));
|
||||
public Task<List<UserModelDto>> GetAllUsersModelDtoAsync() => SessionAsync(x => x.GetAllUsersModelDto().ToList());
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace TIAM.Database.DbContexts.ServiceProviders
|
|||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>());
|
||||
new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
||||
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
||||
|
||||
new ProductEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<Product>());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
using AyCode.Entities.Users;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.DbContexts.Users;
|
||||
|
||||
public interface IUserDbContext : IAcUserDbContextBase<User, Profile, UserToken>, IUserDbSet
|
||||
public interface IUserDbContext : IAcUserDbContextBase<User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider>, IUserDbSet
|
||||
{
|
||||
}
|
||||
|
|
@ -53,8 +53,9 @@ namespace TIAM.Database.DbContexts.Users
|
|||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>());
|
||||
|
||||
modelBuilder.Entity<Product>().BuildProductToServiceProviderRelation();
|
||||
new ProductEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<Product>());
|
||||
|
||||
//modelBuilder.Entity<Product>().BuildProductToServiceProviderRelation();
|
||||
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
using AyCode.Database.DbSets.Users;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.DbSets.Users;
|
||||
|
||||
public interface IUserDbSet : IAcUserDbSet<User, Profile>
|
||||
public interface IUserDbSet : IAcUserDbSet<User, Profile, TiamServiceProvider, UserToServiceProvider>
|
||||
{
|
||||
}
|
||||
|
|
@ -22,12 +22,12 @@ public static class UserDbSetExtensions
|
|||
=> ctx.UsersWithProductRelations(autoInclude).FirstOrDefault(x => x.EmailAddress == email);
|
||||
|
||||
public static UserModelDto? GetUserModelDtoById(this IUserDbSet ctx, Guid userId)
|
||||
=> ctx.GetUsersById(userId).Select(x => new UserModelDto(x, x.Profile, x.UserProductMappings, x.Products)).FirstOrDefault();
|
||||
=> ctx.GetUsersById(userId).Select(user => new UserModelDto(user)).FirstOrDefault();
|
||||
|
||||
public static UserModelDto? GetUserModelDtoByEmail(this IUserDbSet ctx, string email)
|
||||
=> ctx.GetUsersByEmail(email).Select(x => new UserModelDto(x, x.Profile, x.UserProductMappings, x.Products)).FirstOrDefault();
|
||||
=> ctx.GetUsersByEmail(email).Select(user => new UserModelDto(user)).FirstOrDefault();
|
||||
|
||||
public static IQueryable<UserModelDto> GetAllUsersModelDto(this IUserDbSet ctx)
|
||||
=> ctx.Users.Select(x => new UserModelDto(x, x.Profile, x.UserProductMappings, x.Products));
|
||||
=> ctx.Users.Select(user => new UserModelDto(user));
|
||||
|
||||
}
|
||||
|
|
@ -68,9 +68,4 @@ public static class UserEntityTypeBuilderExtensions
|
|||
}
|
||||
|
||||
#endregion UserProductMapping
|
||||
|
||||
public static void BuildUserToServiceProviderRelation<TUser, TProfile>(this EntityTypeBuilder<TUser> modelBuilder) where TUser : class, IUserBase<TProfile> where TProfile : class, IAcProfileBase
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ using AyCode.Database.ModelBuilders.Users;
|
|||
using AyCode.Interfaces.Users;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.ModelBuilders.Users;
|
||||
|
|
@ -15,13 +16,12 @@ public class UserProductMappingEntityTypeDefaultConfiguration : IAcEntityTypeCon
|
|||
}
|
||||
}
|
||||
|
||||
public class UserEntityTypeDefaultConfiguration : IAcEntityTypeConfiguration<User>//AcUserEntityTypeDefaultConfiguration<User>
|
||||
public class UserEntityTypeDefaultConfiguration : AcUserEntityTypeDefaultConfiguration<User, Profile, TiamServiceProvider, UserToServiceProvider> //IAcEntityTypeConfiguration<User>//
|
||||
{
|
||||
public /*override*/ void Configure(EntityTypeBuilder<User> builder)
|
||||
public override void Configure(EntityTypeBuilder<User> builder)
|
||||
{
|
||||
//base.Configure(builder);
|
||||
base.Configure(builder);
|
||||
|
||||
builder.BuildUserToUserProductMappingRelation();
|
||||
builder.BuildUserToServiceProviderRelation<User, Profile>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
using AyCode.Interfaces.ServiceProviders;
|
||||
using AyCode.Interfaces.Users;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Entities.Products;
|
||||
|
||||
public interface IProductRelation
|
||||
{
|
||||
public List<UserProductMapping> UserProductMappings { get; set; }
|
||||
public List<Product> Products { get; set; }
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace TIAM.Entities.Profiles;
|
||||
|
||||
public interface IProfile : IAcProfileBase, IProfileDto
|
||||
public interface IProfile : IAcProfile, IProfileDto
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace TIAM.Entities.Profiles;
|
||||
|
||||
public class Profile : AcProfileBase, IProfile
|
||||
public class Profile : AcProfile, IProfile
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -4,11 +4,12 @@ using AyCode.Entities.ServiceProviders;
|
|||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Entities.ServiceProviders;
|
||||
|
||||
[Table("ServiceProviders")]
|
||||
public class TiamServiceProvider : ServiceProviderBase
|
||||
public class TiamServiceProvider : AcServiceProvider<User, UserToServiceProvider>
|
||||
{
|
||||
public virtual List<Product> Products { get; } = new();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
using AyCode.Interfaces.Users;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
|
||||
namespace TIAM.Entities.Users;
|
||||
|
||||
public interface IUser : IUserBase<Profile>, IUserDto
|
||||
public interface IUser : IAcUser<Profile, TiamServiceProvider, UserToServiceProvider>, IUserDto
|
||||
{
|
||||
public List<Product> Products { get; }
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
using AyCode.Interfaces.Users.Dtos;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
|
||||
namespace TIAM.Entities.Users;
|
||||
|
||||
public interface IUserDto : IAcUserDtoBase
|
||||
public interface IUserDto : IAcUserDtoBase<Profile, TiamServiceProvider, UserToServiceProvider>
|
||||
{ }
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
using AyCode.Interfaces.Users;
|
||||
|
||||
namespace TIAM.Entities.Users;
|
||||
|
||||
public interface IUserToken : IAcUserTokenBase
|
||||
{ }
|
||||
|
||||
|
|
@ -7,10 +7,11 @@ using System.Threading.Tasks;
|
|||
using AyCode.Entities.Users;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
|
||||
namespace TIAM.Entities.Users
|
||||
{
|
||||
public class User : UserBase<Profile>, IUser
|
||||
public class User : AcUser<Profile, TiamServiceProvider, UserToServiceProvider>, IUser
|
||||
{
|
||||
public virtual List<Product> Products { get; } = new();
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ public class UserProductMapping : IEntityGuid, ITimeStampInfo
|
|||
public Guid UserId { get; set; }
|
||||
public Guid ProductId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual User User { get; set; }
|
||||
[JsonIgnore]
|
||||
public virtual Product Product { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
using AyCode.Entities.Users;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
|
||||
namespace TIAM.Entities.Users;
|
||||
|
||||
public class UserToServiceProvider : AcUserToServiceProvider<User, TiamServiceProvider>
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,6 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||
namespace TIAM.Entities.Users;
|
||||
|
||||
[Table("UserToken")]
|
||||
public class UserToken : UserTokenBase
|
||||
public class UserToken : AcUserTokenBase, IUserToken
|
||||
{
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
using AyCode.Interfaces.Users.Dtos;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Models.Dtos.Users;
|
||||
|
|
@ -6,4 +8,8 @@ namespace TIAM.Models.Dtos.Users;
|
|||
public class UserDto : IUserDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid ProfileId { get; }
|
||||
public Profile Profile { get; set; }
|
||||
public List<TiamServiceProvider> ServiceProviders { get; set; }
|
||||
public List<UserToServiceProvider> UserToServiceProviders { get; set; }
|
||||
}
|
||||
|
|
@ -3,25 +3,35 @@ using AyCode.Interfaces.Users.Dtos;
|
|||
using AyCode.Models.Users;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Profiles;
|
||||
|
||||
namespace TIAM.Models.Dtos.Users;
|
||||
|
||||
public class UserModelDto : AcUserModelDtoBase<UserDto, Profile, ProfileDto>
|
||||
public class UserModelDto : AcUserModelDtoBase<UserDto, Profile, ProfileDto, TiamServiceProvider, UserToServiceProvider>, IProductRelation
|
||||
{
|
||||
public List<UserProductMapping> UserProductMappings = new();
|
||||
public List<Product> Products = new();
|
||||
public List<UserProductMapping> UserProductMappings { get; set; }
|
||||
public List<Product> Products { get; set; }
|
||||
|
||||
public UserModelDto(){}
|
||||
public UserModelDto(User user, Profile profile, List<UserProductMapping> userProductMappings, List<Product> products) : base(user, profile)
|
||||
public UserModelDto(User user) : base(user)
|
||||
{
|
||||
foreach (var product in products)
|
||||
if (user.Products.Count == 0) return;
|
||||
|
||||
//így proxy error lesz... - J.
|
||||
//Products = new List<Product>(user.Products);
|
||||
//UserProductMappings = new List<UserProductMapping>(user.UserProductMappings);
|
||||
|
||||
Products = new List<Product>(user.Products.Count);
|
||||
UserProductMappings = new List<UserProductMapping>(user.UserProductMappings.Count);
|
||||
|
||||
foreach (var product in user.Products)
|
||||
{
|
||||
Products.Add(new Product(product.Id, product.ServiceProviderId, product.ProductType, product.Name, product.Description, product.Price, product.JsonDetails));
|
||||
}
|
||||
|
||||
foreach (var userProduct in userProductMappings)
|
||||
foreach (var userProduct in user.UserProductMappings)
|
||||
{
|
||||
UserProductMappings.Add(new UserProductMapping(userProduct.Id, userProduct.UserId, userProduct.ProductId));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ else
|
|||
@foreach (var dest in Users)
|
||||
{
|
||||
<p>
|
||||
@(dest.Profile == null ? dest.UserDto.Id.ToString() : dest.Profile.Name)
|
||||
@(dest.Profile.Name.IsNullOrWhiteSpace() ? dest.Id.ToString() : dest.Profile.Name)
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -38,17 +38,11 @@ namespace TIAMWebApp.Client.Services
|
|||
|
||||
public async Task<UserSessionModel> IsLoggedInAsync(Guid id)
|
||||
{
|
||||
UserSessionModel user = null;
|
||||
//api call to get user
|
||||
var userModelDto = await GetUserByIdAsync(id);
|
||||
|
||||
if (userModelDto != null)
|
||||
{
|
||||
var a = userModelDto.UserProductMappings.FirstOrDefault()?.Product;
|
||||
|
||||
if (a != null)
|
||||
logToBrowserConsole.LogToBC($"{a.Name}");
|
||||
|
||||
//get user's properties
|
||||
var hasProperties = await serviceProviderDataService.GetPropertiesByOwnerIdAsync(userModelDto.Id);
|
||||
|
||||
|
|
@ -56,7 +50,7 @@ namespace TIAMWebApp.Client.Services
|
|||
logToBrowserConsole.LogToBC($"{hasProperties.Count} properties found");
|
||||
|
||||
//create user session model
|
||||
user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto.Profile?.Name, hasProperties, 1);
|
||||
var user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto.Profile?.Name, hasProperties, 1);
|
||||
return user;
|
||||
}
|
||||
else
|
||||
|
|
@ -146,9 +140,11 @@ namespace TIAMWebApp.Client.Services
|
|||
{
|
||||
var url = $"{Setting.BaseUrl}/{APIUrls.GetUserById}";
|
||||
logToBrowserConsole.LogToBC("GetUserByIdAsync url: " + url + ", " + id.ToString());
|
||||
|
||||
var response = await http.PostAsJsonAsync(url, id);
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
var user = JsonConvert.DeserializeObject<UserModelDto>(result);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -344,13 +344,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
public Task<UserModelDto?> GetUserById([FromBody] Guid id)
|
||||
{
|
||||
Logger.Info($"GetUserById called with id: {id}");
|
||||
var result = _userDal.GetUserModelDtoByIdAsync(id);
|
||||
|
||||
//var b = result.UserProductMappings.FirstOrDefault(x => x.Id != null);
|
||||
//var a = JsonSerializer.Serialize(result);
|
||||
//Console.WriteLine($"GetUserById result: {a}");
|
||||
|
||||
return result;
|
||||
return _userDal.GetUserModelDtoByIdAsync(id);
|
||||
}
|
||||
|
||||
private bool VerifyPassword(string password, string hashedPassword)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GoogleApi" Version="5.2.4" />
|
||||
<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" />
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.JSInterop" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue