Compare commits

..

No commits in common. "3bd43a0f0ae05382b9f51e82025b83259adbf1a5" and "52572bd4b5da2ec0435b13b76e1da452e694d291" have entirely different histories.

30 changed files with 62 additions and 153 deletions

View File

@ -12,7 +12,6 @@ using TIAM.Database.DbContexts.ServiceProviders;
using TIAM.Database.DbSets.Permissions; using TIAM.Database.DbSets.Permissions;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users;
namespace TIAM.Database.Test namespace TIAM.Database.Test
{ {
@ -106,37 +105,6 @@ namespace TIAM.Database.Test
Assert.IsNotNull(userProductMapping.Product, "Product is null"); 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] //[TestMethod]
//[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")] //[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
//public void SerializeUser_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString) //public void SerializeUser_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)

View File

@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" 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.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.70" /> <PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" /> <PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" /> <PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0"> <PackageReference Include="coverlet.collector" Version="6.0.0">

View File

@ -14,12 +14,11 @@ using TIAM.Entities.Profiles;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using AyCode.Interfaces.Users.Dtos; using AyCode.Interfaces.Users.Dtos;
using TIAM.Entities.ServiceProviders;
namespace TIAM.Database.Test namespace TIAM.Database.Test
{ {
[TestClass] [TestClass]
public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider> public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, Profile, UserToken>
{ {
private Mock<UserDbContext> _mockContext; private Mock<UserDbContext> _mockContext;
@ -40,38 +39,21 @@ namespace TIAM.Database.Test
[TestMethod] [TestMethod]
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")] [DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
public void GetUserById_ReturnsUser_WhenUserAndRelationsExists(string userIdString) public override void GetUserById_ReturnsUser_WhenUserExists(string userIdString)
{ => base.GetUserById_ReturnsUser_WhenUserExists(userIdString);
var user = AcBase_GetUserById_ReturnsUser_WhenUserExists(userIdString);
Assert.IsTrue(user.ServiceProviders.Count > 0);
Assert.IsTrue(user.UserToServiceProviders.Count > 0);
}
[TestMethod] [TestMethod]
[DataRow("test@tiam.hu")] [DataRow("test@tiam.hu")]
public void GetUserByEmail_ReturnsUser_WhenUserAndRelationsExists(string email) public override void GetUserByEmail_ReturnsUser_WhenUserExists(string email)
{ => base.GetUserByEmail_ReturnsUser_WhenUserExists(email);
var user = AcBase_GetUserByEmail_ReturnsUser_WhenUserExists(email);
Assert.IsTrue(user.ServiceProviders.Count > 0);
Assert.IsTrue(user.UserToServiceProviders.Count > 0);
}
[TestMethod] [TestMethod]
[DataRow("test@tiam.hu")] [DataRow("test@tiam.hu")]
public async Task GetUserByEmailAsync_ReturnsUser_WhenUserAndRelationsExists(string email) public override Task GetUserByEmailAsync_ReturnsUser_WhenUserExists(string email)
{ => base.GetUserByEmailAsync_ReturnsUser_WhenUserExists(email);
var user = await AcBase_GetUserByEmailAsync_ReturnsUser_WhenUserExists(email);
Assert.IsTrue(user.ServiceProviders.Count > 0);
Assert.IsTrue(user.UserToServiceProviders.Count > 0);
}
[TestMethod] [TestMethod]
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")] [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) public async Task SerializeUserModelDto_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
{ {
var userId = Guid.Parse(userIdString); var userId = Guid.Parse(userIdString);
@ -91,13 +73,8 @@ namespace TIAM.Database.Test
Assert.IsNotNull(userModel.UserDto); Assert.IsNotNull(userModel.UserDto);
Assert.IsNotNull(userModel.Profile); 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.Products.Count > 0);
Assert.IsTrue(userModel.UserProductMappings.Count > 0); Assert.IsTrue(userModel.UserProductMappings.Count > 0);
Assert.IsTrue(userModel.ServiceProviders.Count > 0);
Assert.IsTrue(userModel.UserToServiceProviders.Count > 0);
} }
//[TestMethod] //[TestMethod]

View File

@ -36,7 +36,6 @@ namespace TIAM.Database.DataLayers.ServiceProviders
public User? GetUserByEmail(string email, bool autoInclude = false) => Session(x => x.GetUserByEmail(email, autoInclude)); 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 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 UserModelDto? GetUserModelDtoByEmail(string email) => Session(x => x.GetUserModelDtoByEmail(email));
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(x => x.GetUserProductMappingById(userProductMappingId, autoInclude)); public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(x => x.GetUserProductMappingById(userProductMappingId, autoInclude));

View File

@ -11,13 +11,12 @@ using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbContexts.Users; using TIAM.Database.DbContexts.Users;
using TIAM.Database.DbSets.Users; using TIAM.Database.DbSets.Users;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
namespace TIAM.Database.DataLayers.Users namespace TIAM.Database.DataLayers.Users
{ {
public class UserDal : AcUserDalBase<UserDbContext, User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider> public class UserDal : AcUserDalBase<UserDbContext, User, Profile, UserToken>
{ {
public UserDal() : base() public UserDal() : base()
@ -33,7 +32,6 @@ namespace TIAM.Database.DataLayers.Users
return Context.Users.ToListAsync(); 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?> GetUserModelDtoByIdAsync(Guid userId) => SessionAsync(x => x.GetUserModelDtoById(userId));
public Task<UserModelDto?> GetUserModelDtoByEmailAsync(string email) => SessionAsync(x => x.GetUserModelDtoByEmail(email)); public Task<UserModelDto?> GetUserModelDtoByEmailAsync(string email) => SessionAsync(x => x.GetUserModelDtoByEmail(email));
public Task<List<UserModelDto>> GetAllUsersModelDtoAsync() => SessionAsync(x => x.GetAllUsersModelDto().ToList()); public Task<List<UserModelDto>> GetAllUsersModelDtoAsync() => SessionAsync(x => x.GetAllUsersModelDto().ToList());

View File

@ -60,7 +60,7 @@ namespace TIAM.Database.DbContexts.ServiceProviders
base.OnModelCreating(modelBuilder); base.OnModelCreating(modelBuilder);
new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>()); new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>());
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>()); new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
new ProductEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<Product>()); new ProductEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<Product>());
} }

View File

@ -2,11 +2,10 @@
using AyCode.Entities.Users; using AyCode.Entities.Users;
using TIAM.Database.DbSets.Users; using TIAM.Database.DbSets.Users;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
namespace TIAM.Database.DbContexts.Users; namespace TIAM.Database.DbContexts.Users;
public interface IUserDbContext : IAcUserDbContextBase<User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider>, IUserDbSet public interface IUserDbContext : IAcUserDbContextBase<User, Profile, UserToken>, IUserDbSet
{ {
} }

View File

@ -53,9 +53,8 @@ namespace TIAM.Database.DbContexts.Users
base.OnModelCreating(modelBuilder); base.OnModelCreating(modelBuilder);
new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>()); new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>());
new ProductEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<Product>());
//modelBuilder.Entity<Product>().BuildProductToServiceProviderRelation(); modelBuilder.Entity<Product>().BuildProductToServiceProviderRelation();
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>()); //new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
} }
} }

View File

@ -1,10 +1,9 @@
using AyCode.Database.DbSets.Users; using AyCode.Database.DbSets.Users;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.Users; namespace TIAM.Database.DbSets.Users;
public interface IUserDbSet : IAcUserDbSet<User, Profile, TiamServiceProvider, UserToServiceProvider> public interface IUserDbSet : IAcUserDbSet<User, Profile>
{ {
} }

View File

@ -22,12 +22,12 @@ public static class UserDbSetExtensions
=> ctx.UsersWithProductRelations(autoInclude).FirstOrDefault(x => x.EmailAddress == email); => ctx.UsersWithProductRelations(autoInclude).FirstOrDefault(x => x.EmailAddress == email);
public static UserModelDto? GetUserModelDtoById(this IUserDbSet ctx, Guid userId) public static UserModelDto? GetUserModelDtoById(this IUserDbSet ctx, Guid userId)
=> ctx.GetUsersById(userId).Select(user => new UserModelDto(user)).FirstOrDefault(); => ctx.GetUsersById(userId).Select(x => new UserModelDto(x, x.Profile, x.UserProductMappings, x.Products)).FirstOrDefault();
public static UserModelDto? GetUserModelDtoByEmail(this IUserDbSet ctx, string email) public static UserModelDto? GetUserModelDtoByEmail(this IUserDbSet ctx, string email)
=> ctx.GetUsersByEmail(email).Select(user => new UserModelDto(user)).FirstOrDefault(); => ctx.GetUsersByEmail(email).Select(x => new UserModelDto(x, x.Profile, x.UserProductMappings, x.Products)).FirstOrDefault();
public static IQueryable<UserModelDto> GetAllUsersModelDto(this IUserDbSet ctx) public static IQueryable<UserModelDto> GetAllUsersModelDto(this IUserDbSet ctx)
=> ctx.Users.Select(user => new UserModelDto(user)); => ctx.Users.Select(x => new UserModelDto(x, x.Profile, x.UserProductMappings, x.Products));
} }

View File

@ -68,4 +68,9 @@ public static class UserEntityTypeBuilderExtensions
} }
#endregion UserProductMapping #endregion UserProductMapping
public static void BuildUserToServiceProviderRelation<TUser, TProfile>(this EntityTypeBuilder<TUser> modelBuilder) where TUser : class, IUserBase<TProfile> where TProfile : class, IAcProfileBase
{
}
} }

View File

@ -3,7 +3,6 @@ using AyCode.Database.ModelBuilders.Users;
using AyCode.Interfaces.Users; using AyCode.Interfaces.Users;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
namespace TIAM.Database.ModelBuilders.Users; namespace TIAM.Database.ModelBuilders.Users;
@ -16,12 +15,13 @@ public class UserProductMappingEntityTypeDefaultConfiguration : IAcEntityTypeCon
} }
} }
public class UserEntityTypeDefaultConfiguration : AcUserEntityTypeDefaultConfiguration<User, Profile, TiamServiceProvider, UserToServiceProvider> //IAcEntityTypeConfiguration<User>// public class UserEntityTypeDefaultConfiguration : IAcEntityTypeConfiguration<User>//AcUserEntityTypeDefaultConfiguration<User>
{ {
public override void Configure(EntityTypeBuilder<User> builder) public /*override*/ void Configure(EntityTypeBuilder<User> builder)
{ {
base.Configure(builder); //base.Configure(builder);
builder.BuildUserToUserProductMappingRelation(); builder.BuildUserToUserProductMappingRelation();
builder.BuildUserToServiceProviderRelation<User, Profile>();
} }
} }

View File

@ -1,12 +0,0 @@
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; }
}

View File

@ -2,7 +2,7 @@
namespace TIAM.Entities.Profiles; namespace TIAM.Entities.Profiles;
public interface IProfile : IAcProfile, IProfileDto public interface IProfile : IAcProfileBase, IProfileDto
{ {
} }

View File

@ -2,7 +2,7 @@
namespace TIAM.Entities.Profiles; namespace TIAM.Entities.Profiles;
public class Profile : AcProfile, IProfile public class Profile : AcProfileBase, IProfile
{ {
} }

View File

@ -4,12 +4,11 @@ using AyCode.Entities.ServiceProviders;
using AyCode.Interfaces.Entities; using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo; using AyCode.Interfaces.TimeStampInfo;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Users;
namespace TIAM.Entities.ServiceProviders; namespace TIAM.Entities.ServiceProviders;
[Table("ServiceProviders")] [Table("ServiceProviders")]
public class TiamServiceProvider : AcServiceProvider<User, UserToServiceProvider> public class TiamServiceProvider : ServiceProviderBase
{ {
public virtual List<Product> Products { get; } = new(); public virtual List<Product> Products { get; } = new();

View File

@ -1,11 +1,10 @@
using AyCode.Interfaces.Users; using AyCode.Interfaces.Users;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
namespace TIAM.Entities.Users; namespace TIAM.Entities.Users;
public interface IUser : IAcUser<Profile, TiamServiceProvider, UserToServiceProvider>, IUserDto public interface IUser : IUserBase<Profile>, IUserDto
{ {
public List<Product> Products { get; } public List<Product> Products { get; }

View File

@ -2,9 +2,8 @@
using AyCode.Interfaces.Users.Dtos; using AyCode.Interfaces.Users.Dtos;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
namespace TIAM.Entities.Users; namespace TIAM.Entities.Users;
public interface IUserDto : IAcUserDtoBase<Profile, TiamServiceProvider, UserToServiceProvider> public interface IUserDto : IAcUserDtoBase
{ } { }

View File

@ -1,7 +0,0 @@
using AyCode.Interfaces.Users;
namespace TIAM.Entities.Users;
public interface IUserToken : IAcUserTokenBase
{ }

View File

@ -7,11 +7,10 @@ using System.Threading.Tasks;
using AyCode.Entities.Users; using AyCode.Entities.Users;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
namespace TIAM.Entities.Users namespace TIAM.Entities.Users
{ {
public class User : AcUser<Profile, TiamServiceProvider, UserToServiceProvider>, IUser public class User : UserBase<Profile>, IUser
{ {
public virtual List<Product> Products { get; } = new(); public virtual List<Product> Products { get; } = new();

View File

@ -15,7 +15,9 @@ public class UserProductMapping : IEntityGuid, ITimeStampInfo
public Guid UserId { get; set; } public Guid UserId { get; set; }
public Guid ProductId { get; set; } public Guid ProductId { get; set; }
[JsonIgnore]
public virtual User User { get; set; } public virtual User User { get; set; }
[JsonIgnore]
public virtual Product Product { get; set; } public virtual Product Product { get; set; }
public DateTime Created { get; set; } public DateTime Created { get; set; }

View File

@ -1,9 +0,0 @@
using AyCode.Entities.Users;
using TIAM.Entities.ServiceProviders;
namespace TIAM.Entities.Users;
public class UserToServiceProvider : AcUserToServiceProvider<User, TiamServiceProvider>
{
}

View File

@ -5,6 +5,6 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace TIAM.Entities.Users; namespace TIAM.Entities.Users;
[Table("UserToken")] [Table("UserToken")]
public class UserToken : AcUserTokenBase, IUserToken public class UserToken : UserTokenBase
{ {
} }

View File

@ -1,6 +1,4 @@
using AyCode.Interfaces.Users.Dtos; using AyCode.Interfaces.Users.Dtos;
using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
namespace TIAM.Models.Dtos.Users; namespace TIAM.Models.Dtos.Users;
@ -8,8 +6,4 @@ namespace TIAM.Models.Dtos.Users;
public class UserDto : IUserDto public class UserDto : IUserDto
{ {
public Guid Id { get; set; } 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; }
} }

View File

@ -3,35 +3,25 @@ using AyCode.Interfaces.Users.Dtos;
using AyCode.Models.Users; using AyCode.Models.Users;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Profiles; using TIAM.Models.Dtos.Profiles;
namespace TIAM.Models.Dtos.Users; namespace TIAM.Models.Dtos.Users;
public class UserModelDto : AcUserModelDtoBase<UserDto, Profile, ProfileDto, TiamServiceProvider, UserToServiceProvider>, IProductRelation public class UserModelDto : AcUserModelDtoBase<UserDto, Profile, ProfileDto>
{ {
public List<UserProductMapping> UserProductMappings { get; set; } public List<UserProductMapping> UserProductMappings = new();
public List<Product> Products { get; set; } public List<Product> Products = new();
public UserModelDto(){} public UserModelDto(){}
public UserModelDto(User user) : base(user) public UserModelDto(User user, Profile profile, List<UserProductMapping> userProductMappings, List<Product> products) : base(user, profile)
{ {
if (user.Products.Count == 0) return; foreach (var product in products)
//í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)); Products.Add(new Product(product.Id, product.ServiceProviderId, product.ProductType, product.Name, product.Description, product.Price, product.JsonDetails));
} }
foreach (var userProduct in user.UserProductMappings) foreach (var userProduct in userProductMappings)
{ {
UserProductMappings.Add(new UserProductMapping(userProduct.Id, userProduct.UserId, userProduct.ProductId)); UserProductMappings.Add(new UserProductMapping(userProduct.Id, userProduct.UserId, userProduct.ProductId));
} }

View File

@ -13,7 +13,7 @@ else
@foreach (var dest in Users) @foreach (var dest in Users)
{ {
<p> <p>
@(dest.Profile.Name.IsNullOrWhiteSpace() ? dest.Id.ToString() : dest.Profile.Name) @(dest.Profile == null ? dest.UserDto.Id.ToString() : dest.Profile.Name)
</p> </p>
} }
</div> </div>

View File

@ -38,11 +38,17 @@ namespace TIAMWebApp.Client.Services
public async Task<UserSessionModel> IsLoggedInAsync(Guid id) public async Task<UserSessionModel> IsLoggedInAsync(Guid id)
{ {
UserSessionModel user = null;
//api call to get user //api call to get user
var userModelDto = await GetUserByIdAsync(id); var userModelDto = await GetUserByIdAsync(id);
if (userModelDto != null) if (userModelDto != null)
{ {
var a = userModelDto.UserProductMappings.FirstOrDefault()?.Product;
if (a != null)
logToBrowserConsole.LogToBC($"{a.Name}");
//get user's properties //get user's properties
var hasProperties = await serviceProviderDataService.GetPropertiesByOwnerIdAsync(userModelDto.Id); var hasProperties = await serviceProviderDataService.GetPropertiesByOwnerIdAsync(userModelDto.Id);
@ -50,7 +56,7 @@ namespace TIAMWebApp.Client.Services
logToBrowserConsole.LogToBC($"{hasProperties.Count} properties found"); logToBrowserConsole.LogToBC($"{hasProperties.Count} properties found");
//create user session model //create user session model
var user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto.Profile?.Name, hasProperties, 1); user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto.Profile?.Name, hasProperties, 1);
return user; return user;
} }
else else
@ -140,11 +146,9 @@ namespace TIAMWebApp.Client.Services
{ {
var url = $"{Setting.BaseUrl}/{APIUrls.GetUserById}"; var url = $"{Setting.BaseUrl}/{APIUrls.GetUserById}";
logToBrowserConsole.LogToBC("GetUserByIdAsync url: " + url + ", " + id.ToString()); logToBrowserConsole.LogToBC("GetUserByIdAsync url: " + url + ", " + id.ToString());
var response = await http.PostAsJsonAsync(url, id); var response = await http.PostAsJsonAsync(url, id);
var result = await response.Content.ReadAsStringAsync(); var result = await response.Content.ReadAsStringAsync();
var user = JsonConvert.DeserializeObject<UserModelDto>(result); var user = JsonConvert.DeserializeObject<UserModelDto>(result);
return user; return user;
} }

View File

@ -344,7 +344,13 @@ namespace TIAMWebApp.Server.Controllers
public Task<UserModelDto?> GetUserById([FromBody] Guid id) public Task<UserModelDto?> GetUserById([FromBody] Guid id)
{ {
Logger.Info($"GetUserById called with id: {id}"); Logger.Info($"GetUserById called with id: {id}");
return _userDal.GetUserModelDtoByIdAsync(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;
} }
private bool VerifyPassword(string password, string hashedPassword) private bool VerifyPassword(string password, string hashedPassword)

View File

@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="GoogleApi" Version="5.3.0" /> <PackageReference Include="GoogleApi" Version="5.2.4" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.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.AspNetCore.Components.WebAssembly.Server" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />

View File

@ -18,6 +18,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.0" /> <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" /> <PackageReference Include="Microsoft.JSInterop" Version="8.0.0" />
</ItemGroup> </ItemGroup>