Merge branch 'master' of http://git2.aycode.com/Adam/TourIAm
This commit is contained in:
commit
08b347e85b
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AyCode.Database.DataLayers.Users;
|
||||
using Newtonsoft.Json;
|
||||
using TIAM.Database.DataLayers.ServiceProviders;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
using TIAM.Database.DbContexts.ServiceProviders;
|
||||
|
|
@ -97,11 +98,35 @@ namespace TIAM.Database.Test
|
|||
public void GetUserProductMappingById_ReturnsUserProductMapping_WherHasUserAndProductRelation(string userProductMappingIdString)
|
||||
{
|
||||
var userProductMappingId = Guid.Parse(userProductMappingIdString);
|
||||
var userProductMapping = Dal.GetUserProductMappingById(userProductMappingId);
|
||||
var userProductMapping = Dal.GetUserProductMappingById(userProductMappingId, true);
|
||||
|
||||
Assert.IsNotNull(userProductMapping);
|
||||
Assert.IsNotNull(userProductMapping.User, "User is null");
|
||||
Assert.IsNotNull(userProductMapping.Product, "Product is null");
|
||||
}
|
||||
|
||||
//[TestMethod]
|
||||
//[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
|
||||
//public void SerializeUser_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
|
||||
//{
|
||||
// var userId = Guid.Parse(userIdString);
|
||||
// var user = Dal.GetUserProductMappingById(userId);
|
||||
|
||||
// JsonSerializerSettings options = new()
|
||||
// {
|
||||
// ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
// //NullValueHandling = NullValueHandling.Ignore
|
||||
// };
|
||||
|
||||
// var serializedUser = JsonConvert.SerializeObject(user, options);
|
||||
// user = JsonConvert.DeserializeObject<User>(serializedUser);
|
||||
|
||||
// Assert.IsNotNull(user);
|
||||
// Assert.IsNotNull(user.Products);
|
||||
// Assert.IsNotNull(user.UserProductMappings);
|
||||
// Assert.IsNotNull(user.UserProductMappings.FirstOrDefault()?.Product);
|
||||
|
||||
// Assert.IsTrue(user.Products.Count > 0);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,15 @@ using System.Text.Json.Serialization;
|
|||
using System.Text.Json;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
using TIAM.Database.DbContexts.Users;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using AyCode.Interfaces.Users.Dtos;
|
||||
|
||||
namespace TIAM.Database.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, UserToken>
|
||||
public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, Profile, UserToken>
|
||||
{
|
||||
private Mock<UserDbContext> _mockContext;
|
||||
|
||||
|
|
@ -51,23 +54,27 @@ namespace TIAM.Database.Test
|
|||
|
||||
[TestMethod]
|
||||
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
|
||||
public void SerializeUser_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
|
||||
public async Task SerializeUserModelDto_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
|
||||
{
|
||||
var userId = Guid.Parse(userIdString);
|
||||
var user = Dal.GetUserById(userId);
|
||||
|
||||
JsonSerializerSettings options = new()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
//NullValueHandling = NullValueHandling.Ignore
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
var serializedUser = JsonConvert.SerializeObject(user, options);
|
||||
user = JsonConvert.DeserializeObject<User>(serializedUser);
|
||||
var userModel = await Dal.GetUserModelDtoByIdAsync(userId).ConfigureAwait(false);
|
||||
|
||||
Assert.IsNotNull(user);
|
||||
Assert.IsNotNull(user.UserProductMappings);
|
||||
//Assert.IsNotNull(user.UserProductMappings.FirstOrDefault()?.Product);
|
||||
var serializedUserModel = JsonConvert.SerializeObject(userModel, options);
|
||||
userModel = JsonConvert.DeserializeObject<UserModelDto>(serializedUserModel);
|
||||
|
||||
Assert.IsNotNull(userModel);
|
||||
Assert.IsNotNull(userModel.UserDto);
|
||||
Assert.IsNotNull(userModel.Profile);
|
||||
|
||||
Assert.IsTrue(userModel.Products.Count > 0);
|
||||
Assert.IsTrue(userModel.UserProductMappings.Count > 0);
|
||||
}
|
||||
|
||||
//[TestMethod]
|
||||
|
|
|
|||
|
|
@ -8,14 +8,15 @@ using Microsoft.EntityFrameworkCore;
|
|||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Products.DTOs;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Database.DbContexts.ServiceProviders;
|
||||
using TIAM.Database.DbSets.Permissions;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Products.DTOs;
|
||||
using AyCode.Database.DataLayers;
|
||||
using AyCode.Database.DbSets.Users;
|
||||
using TIAM.Database.DbSets.Products;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
|
||||
|
||||
namespace TIAM.Database.DataLayers.ServiceProviders
|
||||
|
|
@ -31,9 +32,13 @@ namespace TIAM.Database.DataLayers.ServiceProviders
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
public User? GetUserById(Guid userId, bool autoInclude = false) => Session(x => x.GetUserById(userId, autoInclude));
|
||||
public User? GetUserByEmail(string email, bool autoInclude = false) => Session(x => x.GetUserByEmail(email, autoInclude));
|
||||
|
||||
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId) => Session(x => x.GetUserProductMappingById(userProductMappingId));
|
||||
public UserModelDto? GetUserModelDtoById(Guid userId) => Session(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));
|
||||
|
||||
#region ServiceProviders
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public static class ServiceProviderDalExtension
|
|||
existingProduct.Description = product.Description;
|
||||
existingProduct.Price = product.Price;
|
||||
existingProduct.JsonDetails = product.JsonDetails;
|
||||
existingProduct.UserMediaId = product.UserMediaId;
|
||||
//existingProduct.UserMediaId = product.UserMediaId;
|
||||
existingProduct.ProductType = product.ProductType;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,18 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using AyCode.Database.DataLayers;
|
||||
using AyCode.Database.DataLayers.Users;
|
||||
using AyCode.Database.DbSets.Users;
|
||||
using AyCode.Entities.Users;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Database.DbContexts.Users;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
|
||||
namespace TIAM.Database.DataLayers.Users
|
||||
{
|
||||
public class UserDal : AcUserDalBase<UserDbContext, User, UserToken>
|
||||
public class UserDal : AcUserDalBase<UserDbContext, User, Profile, UserToken>
|
||||
{
|
||||
|
||||
public UserDal() : base()
|
||||
|
|
@ -28,14 +32,9 @@ namespace TIAM.Database.DataLayers.Users
|
|||
return Context.Users.ToListAsync();
|
||||
}
|
||||
|
||||
//public Task<User?> GetUserByEmailAsync(string email)
|
||||
//{
|
||||
// Console.WriteLine($"Getting user from db {email}");
|
||||
// //var emailLower = email.ToLower();
|
||||
|
||||
// return Context.GetUserByEmail(email);
|
||||
// //return Context.Users.SingleOrDefaultAsync(x=>x.Email.ToLower() == emailLower);
|
||||
//}
|
||||
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());
|
||||
|
||||
public Task<User?> GetUserByPhoneNumberAsync(string phoneNumber)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace TIAM.Database.DbContexts
|
|||
{
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
|
||||
optionsBuilder.UseLazyLoadingProxies(false);
|
||||
optionsBuilder.UseLazyLoadingProxies(true);
|
||||
optionsBuilder.EnableDetailedErrors(true);
|
||||
|
||||
//optionsBuilder.UseSqlServer(Configuration.GetConnectionString("DeveloperDbConnection"));
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
using AyCode.Database.DbContexts.Users;
|
||||
using AyCode.Entities.Users;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.DbContexts.Users;
|
||||
|
||||
public interface IUserDbContext : IAcUserDbContextBase<User, UserToken>
|
||||
public interface IUserDbContext : IAcUserDbContextBase<User, Profile, UserToken>, IUserDbSet
|
||||
{
|
||||
}
|
||||
|
|
@ -11,8 +11,10 @@ using AyCode.Entities.Users;
|
|||
using AyCode.Interfaces.Users;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using TIAM.Database.ModelBuilders.Products;
|
||||
using TIAM.Database.ModelBuilders.Users;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.DbContexts.Users
|
||||
|
|
@ -51,7 +53,9 @@ namespace TIAM.Database.DbContexts.Users
|
|||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>());
|
||||
new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
||||
|
||||
modelBuilder.Entity<Product>().BuildProductToServiceProviderRelation();
|
||||
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
using AyCode.Database.DbSets.Users;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.DbSets.Users;
|
||||
|
||||
public interface IUserDbSet : IAcUserDbSet<User>
|
||||
public interface IUserDbSet : IAcUserDbSet<User, Profile>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
using System.Security.Cryptography.X509Certificates;
|
||||
using AyCode.Database.DbSets.Users;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
|
||||
namespace TIAM.Database.DbSets.Users;
|
||||
|
||||
|
|
@ -13,16 +15,19 @@ public static class UserDbSetExtensions
|
|||
.ThenInclude(x => x.Product)
|
||||
: ctx.Users;
|
||||
|
||||
//public static IQueryable<User> UsersWithServiceProviderRelations(this IUserDbSet ctx, bool autoInclude = true)
|
||||
// => autoInclude
|
||||
// ? ctx.Users
|
||||
// .Include(x => x.UserProductMappings)
|
||||
// .ThenInclude(x => x.Product)
|
||||
// : ctx.Users;
|
||||
|
||||
public static User? GetUserById(this IUserDbSet ctx, Guid userId, bool autoInclude)
|
||||
=> ctx.UsersWithProductRelations(autoInclude).FirstOrDefault(x => x.Id == userId);
|
||||
|
||||
public static User? GetUserByEmail(this IUserDbSet ctx, string email, bool autoInclude)
|
||||
=> 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();
|
||||
|
||||
public static UserModelDto? GetUserModelDtoByEmail(this IUserDbSet ctx, string email)
|
||||
=> ctx.GetUsersByEmail(email).Select(x => new UserModelDto(x, x.Profile, x.UserProductMappings, x.Products)).FirstOrDefault();
|
||||
|
||||
public static IQueryable<UserModelDto> GetAllUsersModelDto(this IUserDbSet ctx)
|
||||
=> ctx.Users.Select(x => new UserModelDto(x, x.Profile, x.UserProductMappings, x.Products));
|
||||
|
||||
}
|
||||
|
|
@ -12,15 +12,15 @@ public static class UserProductMappingDbSetExtensions
|
|||
: ctx.UserProductMappings;
|
||||
|
||||
|
||||
public static UserProductMapping? GetUserProductMappingById(this IUserProductMappingDbSet ctx, Guid userProductMappingId)
|
||||
=> ctx.UserProductMappingsWithRelations().FirstOrDefault(x => x.Id == userProductMappingId);
|
||||
public static UserProductMapping? GetUserProductMappingById(this IUserProductMappingDbSet ctx, Guid userProductMappingId, bool autoInclude = true)
|
||||
=> ctx.UserProductMappingsWithRelations(autoInclude).FirstOrDefault(x => x.Id == userProductMappingId);
|
||||
|
||||
public static UserProductMapping? GetUserProductMapping(this IUserProductMappingDbSet ctx, Guid userId, Guid productId)
|
||||
=> ctx.UserProductMappingsWithRelations().FirstOrDefault(x => x.UserId == userId && x.ProductId == productId);
|
||||
public static UserProductMapping? GetUserProductMapping(this IUserProductMappingDbSet ctx, Guid userId, Guid productId, bool autoInclude = true)
|
||||
=> ctx.UserProductMappingsWithRelations(autoInclude).FirstOrDefault(x => x.UserId == userId && x.ProductId == productId);
|
||||
|
||||
public static IQueryable<UserProductMapping> GetUserProductMappingsByUserId(this IUserProductMappingDbSet ctx, Guid userId)
|
||||
=> ctx.UserProductMappingsWithRelations().Where(x => x.UserId == userId);
|
||||
public static IQueryable<UserProductMapping> GetUserProductMappingsByUserId(this IUserProductMappingDbSet ctx, Guid userId, bool autoInclude = true)
|
||||
=> ctx.UserProductMappingsWithRelations(autoInclude).Where(x => x.UserId == userId);
|
||||
|
||||
public static IQueryable<UserProductMapping> GetUserProductMappingsByProductId(this IUserProductMappingDbSet ctx, Guid productId)
|
||||
=> ctx.UserProductMappingsWithRelations().Where(x => x.ProductId == productId);
|
||||
public static IQueryable<UserProductMapping> GetUserProductMappingsByProductId(this IUserProductMappingDbSet ctx, Guid productId, bool autoInclude = true)
|
||||
=> ctx.UserProductMappingsWithRelations(autoInclude).Where(x => x.ProductId == productId);
|
||||
}
|
||||
|
|
@ -12,10 +12,16 @@ public static class ProductEntityTypeBuilderExtensions
|
|||
public static void BuildProductToUserProductMappingRelation(this EntityTypeBuilder<Product> modelBuilder, bool autoInclude = true)
|
||||
{
|
||||
modelBuilder
|
||||
.HasMany(e => e.UserProductMappings)
|
||||
.WithOne(e => e.Product).HasForeignKey(x => x.ProductId);
|
||||
.HasMany(e => e.Users)
|
||||
.WithMany(e => e.Products)
|
||||
.UsingEntity<UserProductMapping>();
|
||||
|
||||
//modelBuilder
|
||||
// .HasMany(e => e.UserProductMappings)
|
||||
// .WithOne(e => e.Product).HasForeignKey(x => x.ProductId);
|
||||
|
||||
modelBuilder.Navigation(e => e.UserProductMappings).AutoInclude(autoInclude);
|
||||
modelBuilder.Navigation(e => e.Users).AutoInclude(autoInclude);
|
||||
}
|
||||
|
||||
public static void BuildProductToServiceProviderRelation(this EntityTypeBuilder<Product> modelBuilder, bool autoInclude = true)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class ProductEntityTypeDefaultConfiguration : IAcEntityTypeConfiguration<
|
|||
{
|
||||
public void Configure(EntityTypeBuilder<Product> builder)
|
||||
{
|
||||
builder.BuildProductToUserProductMappingRelation();
|
||||
//builder.BuildProductToUserProductMappingRelation();
|
||||
builder.BuildProductToServiceProviderRelation();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.Numerics;
|
||||
using AyCode.Interfaces.Profiles;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
|
|
@ -13,17 +14,20 @@ public static class UserEntityTypeBuilderExtensions
|
|||
|
||||
public static void BuildUserToUserProductMappingRelation(this EntityTypeBuilder<User> modelBuilder, bool autoInclude = true)
|
||||
{
|
||||
//modelBuilder
|
||||
// .HasMany(e => e.Products)
|
||||
// .WithMany(e => e.Users)
|
||||
//.UsingEntity<UserProductMapping>();
|
||||
|
||||
modelBuilder
|
||||
.HasMany(e => e.UserProductMappings)
|
||||
.WithOne(e => e.User).HasForeignKey(x => x.UserId);
|
||||
//.WithMany(e => e.User).
|
||||
//.UsingEntity<UserProductMapping>.HasForeignKey(x => x.UserId);
|
||||
.HasMany(e => e.Products)
|
||||
.WithMany(e => e.Users)
|
||||
.UsingEntity<UserProductMapping>();
|
||||
//l => l.HasOne<Product>().WithMany(x=>x.UserProductMappings).HasForeignKey(e => e.ProductId),
|
||||
//r => r.HasOne<User>().WithMany(x=>x.UserProductMappings).HasForeignKey(e => e.UserId));
|
||||
|
||||
//modelBuilder
|
||||
// .HasMany(e => e.UserProductMappings)
|
||||
// .WithOne(e => e.User).HasForeignKey(x => x.UserId);
|
||||
// //.WithMany(e => e.User).
|
||||
// //.UsingEntity<UserProductMapping>.HasForeignKey(x => x.UserId);
|
||||
|
||||
modelBuilder.Navigation(e => e.Products).AutoInclude(autoInclude);
|
||||
modelBuilder.Navigation(e => e.UserProductMappings).AutoInclude(autoInclude);
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +69,7 @@ public static class UserEntityTypeBuilderExtensions
|
|||
|
||||
#endregion UserProductMapping
|
||||
|
||||
public static void BuildUserToServiceProviderRelation<TUser>(this EntityTypeBuilder<TUser> modelBuilder) where TUser : class, IUserBase
|
||||
public static void BuildUserToServiceProviderRelation<TUser, TProfile>(this EntityTypeBuilder<TUser> modelBuilder) where TUser : class, IUserBase<TProfile> where TProfile : class, IAcProfileBase
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using AyCode.Database.ModelBuilders.Users;
|
||||
using AyCode.Interfaces.Users;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.ModelBuilders.Users;
|
||||
|
|
@ -21,6 +22,6 @@ public class UserEntityTypeDefaultConfiguration : IAcEntityTypeConfiguration<Use
|
|||
//base.Configure(builder);
|
||||
|
||||
builder.BuildUserToUserProductMappingRelation();
|
||||
builder.BuildUserToServiceProviderRelation();
|
||||
builder.BuildUserToServiceProviderRelation<User, Profile>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Models\TIAM.Models.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -14,12 +14,14 @@ public class Product : ProductBase
|
|||
public Guid ServiceProviderId { get; set; }
|
||||
|
||||
public virtual TiamServiceProvider ServiceProvider { get; set; }
|
||||
|
||||
public virtual List<User> Users { get; } = new();
|
||||
public virtual List<UserProductMapping> UserProductMappings { get; } = new();
|
||||
|
||||
public Product(){}
|
||||
|
||||
public Product(Guid ownerId, ProductType productType, Guid userMediaId, string name, string description, float price, string jsonDetails) : this(Guid.NewGuid(), ownerId, productType, userMediaId, name, description, price, jsonDetails) { }
|
||||
public Product(Guid id, Guid serviceProviderId, ProductType productType, Guid userMediaId, string name, string description, float price, string jsonDetails) : base(id, productType, userMediaId, name, description, price, jsonDetails)
|
||||
public Product(Guid ownerId, ProductType productType, string name, string description, float price, string jsonDetails) : this(Guid.NewGuid(), ownerId, productType, name, description, price, jsonDetails) { }
|
||||
public Product(Guid id, Guid serviceProviderId, ProductType productType, string name, string description, float price, string jsonDetails) : base(id, productType, name, description, price, jsonDetails)
|
||||
{
|
||||
ServiceProviderId = serviceProviderId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public abstract class ProductBase : IEntityGuid, ITimeStampInfo
|
|||
public Guid Id { get; set; }
|
||||
|
||||
public ProductType ProductType { get; set; }
|
||||
public Guid? UserMediaId { get; set; }
|
||||
//public Guid? UserMediaId { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
|
@ -25,11 +25,11 @@ public abstract class ProductBase : IEntityGuid, ITimeStampInfo
|
|||
|
||||
protected ProductBase(){}
|
||||
|
||||
protected ProductBase(Guid id, ProductType type, Guid userMediaId, string name, string description, float price, string jsonDetails)
|
||||
protected ProductBase(Guid id, ProductType type, string name, string description, float price, string jsonDetails)
|
||||
{
|
||||
Id = id;
|
||||
ProductType = type;
|
||||
UserMediaId = userMediaId;
|
||||
//UserMediaId = userMediaId;
|
||||
Name = name;
|
||||
Description = description;
|
||||
Price = price;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
using AyCode.Interfaces.Profiles;
|
||||
|
||||
namespace TIAM.Entities.Profiles;
|
||||
|
||||
public interface IProfile : IAcProfileBase, IProfileDto
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
using AyCode.Interfaces.Profiles.Dtos;
|
||||
|
||||
namespace TIAM.Entities.Profiles;
|
||||
|
||||
public interface IProfileDto : IAcProfileDtoBase
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
using AyCode.Entities.Profiles;
|
||||
|
||||
namespace TIAM.Entities.Profiles;
|
||||
|
||||
public class Profile : AcProfileBase, IProfile
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using AyCode.Interfaces.Users;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Profiles;
|
||||
|
||||
namespace TIAM.Entities.Users;
|
||||
|
||||
public interface IUser : IUserBase<Profile>, IUserDto
|
||||
{
|
||||
public List<Product> Products { get; }
|
||||
|
||||
//public ServiceProvider ServiceProvider { get; set; }
|
||||
public List<UserProductMapping> UserProductMappings { get; }
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using AyCode.Interfaces.Users;
|
||||
using AyCode.Interfaces.Users.Dtos;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Profiles;
|
||||
|
||||
namespace TIAM.Entities.Users;
|
||||
|
||||
public interface IUserDto : IAcUserDtoBase
|
||||
{ }
|
||||
|
|
@ -6,15 +6,16 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using AyCode.Entities.Users;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Profiles;
|
||||
|
||||
namespace TIAM.Entities.Users
|
||||
{
|
||||
public class User : UserBase
|
||||
public class User : UserBase<Profile>, IUser
|
||||
{
|
||||
//public virtual List<Product> Products { get; } = new();
|
||||
public virtual List<Product> Products { get; } = new();
|
||||
|
||||
//public virtual ServiceProvider ServiceProvider { get; set; } = new();
|
||||
public virtual List<UserProductMapping> UserProductMappings { get; set; } = new();
|
||||
public virtual List<UserProductMapping> UserProductMappings { get; } = new();
|
||||
|
||||
public User() { }
|
||||
public User(string email, string password) : this(Guid.NewGuid(), email, password) { }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
using TIAM.Entities.Profiles;
|
||||
|
||||
namespace TIAM.Models.Dtos.Profiles;
|
||||
|
||||
public class ProfileDto : IProfileDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid OwnerId { get; set; }
|
||||
public Guid? UserMediaId { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
public string? ThumbnailUrl { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using AyCode.Interfaces.Users.Dtos;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Models.Dtos.Users;
|
||||
|
||||
public class UserDto : IUserDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
using AyCode.Entities.Profiles;
|
||||
using AyCode.Interfaces.Users.Dtos;
|
||||
using AyCode.Models.Users;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Profiles;
|
||||
|
||||
namespace TIAM.Models.Dtos.Users;
|
||||
|
||||
public class UserModelDto : AcUserModelDtoBase<UserDto, Profile, ProfileDto>
|
||||
{
|
||||
public List<UserProductMapping> UserProductMappings = new();
|
||||
public List<Product> Products = new();
|
||||
|
||||
public UserModelDto(){}
|
||||
public UserModelDto(User user, Profile profile, List<UserProductMapping> userProductMappings, List<Product> products) : base(user, profile)
|
||||
{
|
||||
foreach (var product in products)
|
||||
{
|
||||
Products.Add(new Product(product.Id, product.ServiceProviderId, product.ProductType, product.Name, product.Description, product.Price, product.JsonDetails));
|
||||
}
|
||||
|
||||
foreach (var userProduct in userProductMappings)
|
||||
{
|
||||
UserProductMappings.Add(new UserProductMapping(userProduct.Id, userProduct.UserId, userProduct.ProductId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Dtos\Profiles\" />
|
||||
<Folder Include="Dtos\UserProductMappings\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TIAM.Core\TIAM.Core.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="AyCode.Core">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Entities">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Entities.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Interfaces">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Interfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Models">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -3,6 +3,7 @@ using System.Text;
|
|||
using AyCode.Interfaces.StorageHandlers;
|
||||
using Newtonsoft.Json;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using TIAMWebApp.Shared.Application.Interfaces;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
||||
|
|
@ -49,7 +50,7 @@ namespace TIAMMobileApp.Services
|
|||
{
|
||||
|
||||
var hasProperties = await _serviceProviderDataService.GetPropertiesByOwnerIdAsync(dbUser.Id);
|
||||
var user = new UserSessionModel(dbUser.Id, UserType.User, dbUser.EmailAddress, hasProperties, 1);
|
||||
var user = new UserSessionModel(dbUser.Id, UserType.User, dbUser.Profile?.Name, hasProperties, 1);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
|
@ -117,14 +118,14 @@ namespace TIAMMobileApp.Services
|
|||
return (isSuccess, result);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<User>?> GetUsersAsync()
|
||||
public async Task<IEnumerable<UserModelDto>?> GetUsersAsync()
|
||||
{
|
||||
return await http.GetFromJsonAsync<IEnumerable<User>>(APIUrls.GetUsers);
|
||||
return await http.GetFromJsonAsync<IEnumerable<UserModelDto>>(APIUrls.GetUsers);
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserByEmailAsync(string email)
|
||||
public async Task<UserModelDto?> GetUserByEmailAsync(string email)
|
||||
{
|
||||
return await http.GetFromJsonAsync<User?>(APIUrls.GetUserByEmail);
|
||||
return await http.GetFromJsonAsync<UserModelDto?>(APIUrls.GetUserByEmail);
|
||||
}
|
||||
public async Task<User?> GetUserByIdAsync(Guid Id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ Loading....
|
|||
string _email = jsontoken.Claims.First(claim => claim.Type == JwtRegisteredClaimNames.Email).Value;
|
||||
var user = await UserDataService.IsLoggedInAsync(Guid.Parse(_userId));
|
||||
sessionService.User = user;
|
||||
logToBrowserConsole.LogToBC($"Saved user in db is: {user.Email}, setting autenthicated state");
|
||||
logToBrowserConsole.LogToBC($"Saved user in db is: {user.DisplayName}, setting autenthicated state");
|
||||
sessionService.IsAuthenticated = true;
|
||||
NavManager.NavigateTo("/index");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Email = sessionService.User.Email;
|
||||
Email = sessionService.User.DisplayName;
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<p class="tm-8 cw-480 mt-2">
|
||||
<h3> @Localizer.GetString("DestinationName")</h3>
|
||||
@FormSubmitResult
|
||||
@_formSubmitResult
|
||||
</p>
|
||||
|
||||
@code {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
public partial class InputWizard : ComponentBase
|
||||
{
|
||||
[Inject]
|
||||
LogToBrowserConsole logToBrowserConsole { get; set; }
|
||||
public required LogToBrowserConsole LogToBrowserConsole { get; set; }
|
||||
|
||||
public Dictionary<int, Guid> FormSteps { get; set; } = new Dictionary<int, Guid>();
|
||||
public int CurrentStep { get; set; } = 0;
|
||||
|
|
@ -28,37 +28,37 @@ namespace TIAMSharedUI.Pages.Components
|
|||
public object Data { get; set; } = new object();
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<object> onSubmit { get; set; }
|
||||
public EventCallback<object> OnSubmit { get; set; }
|
||||
|
||||
|
||||
string PhoneMask { get; set; } = "(999)000-0000";
|
||||
string FormSubmitResult = "";
|
||||
private string spinnerClass = "";
|
||||
string _phoneMask = "(999)000-0000";
|
||||
string _formSubmitResult = "";
|
||||
private string _spinnerClass = "";
|
||||
|
||||
async Task HandleValidSubmit()
|
||||
{
|
||||
spinnerClass = "spinner-border spinner-border-sm";
|
||||
_spinnerClass = "spinner-border spinner-border-sm";
|
||||
await Task.Delay(500);
|
||||
FormSubmitResult = "You have been registred successully.";
|
||||
spinnerClass = "";
|
||||
_formSubmitResult = "You have been registred successully.";
|
||||
_spinnerClass = "";
|
||||
|
||||
await onSubmit.InvokeAsync(Data);
|
||||
await OnSubmit.InvokeAsync(Data);
|
||||
|
||||
}
|
||||
void HandleInvalidSubmit()
|
||||
{
|
||||
FormSubmitResult = "Please correct all errors";
|
||||
_formSubmitResult = "Please correct all errors";
|
||||
}
|
||||
|
||||
public void OnNext(MouseEventArgs args)
|
||||
{
|
||||
logToBrowserConsole.LogToBC("OnNext called");
|
||||
LogToBrowserConsole.LogToBC("OnNext called");
|
||||
CurrentStep++;
|
||||
}
|
||||
|
||||
public void OnPrevious(MouseEventArgs args)
|
||||
{
|
||||
logToBrowserConsole.LogToBC("OnPrev called");
|
||||
LogToBrowserConsole.LogToBC("OnPrev called");
|
||||
CurrentStep--;
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
{
|
||||
|
||||
var _type = Data.GetType();
|
||||
logToBrowserConsole.LogToBC("Hellooooo " + _type.AssemblyQualifiedName);
|
||||
LogToBrowserConsole.LogToBC("Hellooooo " + _type.AssemblyQualifiedName);
|
||||
|
||||
var propertyList = _type.GetProperties();
|
||||
//var propertyList = typeof(TestUserData).GetProperties();
|
||||
|
|
@ -100,7 +100,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
var access = Expression.Property(Expression.Constant(Data), property.Name);
|
||||
var lambda = Expression.Lambda(typeof(Func<>).MakeGenericType(property.PropertyType), access);
|
||||
|
||||
logToBrowserConsole.LogToBC(lambda.ToString());
|
||||
LogToBrowserConsole.LogToBC(lambda.ToString());
|
||||
|
||||
layoutItemBuilder.OpenElement(i++, "div");//open div
|
||||
layoutItemBuilder.AddAttribute(i++, "id", _stepID.ToString());
|
||||
|
|
@ -116,7 +116,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
layoutItemBuilder.AddAttribute(i++, "ColSpanMd", 12);
|
||||
//layoutItemBuilder.AddAttribute(i++, "CssClass", "form-field");
|
||||
|
||||
layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment<Object>)((context) => ((editor) =>
|
||||
layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment<object>)((context) => ((editor) =>
|
||||
{
|
||||
var j = 0;
|
||||
switch (attrList.DataType)
|
||||
|
|
@ -125,11 +125,11 @@ namespace TIAMSharedUI.Pages.Components
|
|||
case DataType.Text:
|
||||
{
|
||||
editor.OpenComponent<DxTextBox>(j++);
|
||||
logToBrowserConsole.LogToBC($"{property.Name}, {property.PropertyType}");
|
||||
LogToBrowserConsole.LogToBC($"{property.Name}, {property.PropertyType}");
|
||||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
|
|
@ -141,17 +141,17 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.AddAttribute(j++, "NullText", "Password");
|
||||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
case DataType.PhoneNumber:
|
||||
{
|
||||
editor.OpenComponent<DxMaskedInput<String>>(j++);
|
||||
editor.OpenComponent<DxMaskedInput<string>>(j++);
|
||||
editor.AddAttribute(j++, "Value", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "Mask", PhoneMask);
|
||||
editor.AddAttribute(j++, "Mask", _phoneMask);
|
||||
editor.AddAttribute(j++, "ValueExpression", lambda);
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.OpenComponent<DxDateEdit<DateTime>>(j);
|
||||
editor.AddAttribute(j++, "Date", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "DateExpression", lambda);
|
||||
editor.AddAttribute(j++, "DateChanged", EventCallback.Factory.Create<System.DateTime>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "DateChanged", EventCallback.Factory.Create<DateTime>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.AddAttribute(j++, "Mask", "n6");
|
||||
editor.AddAttribute(j++, "ValueExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.Double>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<double>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
|
|
@ -191,18 +191,18 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.AddAttribute(j++, "Mask", "n0");
|
||||
editor.AddAttribute(j++, "ValueExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.Int32>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<int>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
else if (property.PropertyType == typeof(string) && property.Name == "Occupation")
|
||||
{
|
||||
|
||||
editor.OpenComponent<DxComboBox<String, String>>(j);
|
||||
editor.OpenComponent<DxComboBox<string, string>>(j);
|
||||
editor.AddAttribute(j++, "Data", AdditionalData.Occupations);
|
||||
editor.AddAttribute(j++, "Value", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "ValueExpression", lambda);
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
|
||||
|
|
@ -260,14 +260,14 @@ namespace TIAMSharedUI.Pages.Components
|
|||
layoutItemBuilder.CloseElement();
|
||||
|
||||
|
||||
logToBrowserConsole.LogToBC($"loop {j}, {propertyList.Length}");
|
||||
LogToBrowserConsole.LogToBC($"loop {j}, {propertyList.Length}");
|
||||
j++;
|
||||
|
||||
}
|
||||
layoutItemBuilder.OpenComponent<DxFormLayoutItem>(i++);
|
||||
layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment<Object>)((context) => ((editor) =>
|
||||
layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment<object>)((context) => ((editor) =>
|
||||
{
|
||||
logToBrowserConsole.LogToBC($"Submit button {CurrentStep}, {propertyList.Length}");
|
||||
LogToBrowserConsole.LogToBC($"Submit button {CurrentStep}, {propertyList.Length}");
|
||||
editor.OpenComponent<DxButton>(i++);
|
||||
editor.AddAttribute(i++, "SubmitFormOnClick", true);
|
||||
editor.AddAttribute(i++, "Text", "Submit");
|
||||
|
|
@ -281,7 +281,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.AddAttribute(i++, "Visible", false);
|
||||
}
|
||||
editor.OpenElement(i++, "span");
|
||||
editor.AddAttribute(i++, "class", spinnerClass);
|
||||
editor.AddAttribute(i++, "class", _spinnerClass);
|
||||
editor.CloseElement();
|
||||
editor.CloseComponent();
|
||||
})));
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Email = sessionService.User.Email;
|
||||
Email = sessionService.User.DisplayName;
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
@if (Users == null)
|
||||
@using AyCode.Utils.Extensions
|
||||
@if (Users == null)
|
||||
{
|
||||
<p>
|
||||
<em>Loading ...</em>
|
||||
|
|
@ -11,7 +12,9 @@ else
|
|||
|
||||
@foreach (var dest in Users)
|
||||
{
|
||||
<p>@dest.EmailAddress</p>
|
||||
<p>
|
||||
@(dest.Profile == null ? dest.UserDto.Id.ToString() : dest.Profile.Name)
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using TIAMWebApp.Shared.Application.Interfaces;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
|
||||
|
|
@ -19,7 +20,7 @@ namespace TIAMSharedUI.Pages
|
|||
get;
|
||||
set;
|
||||
}
|
||||
public List<TIAM.Entities.Users.User>? Users
|
||||
public required List<UserModelDto> Users
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<hr/>
|
||||
<DbTestComponent></DbTestComponent>
|
||||
|
||||
<InputWizard Data=@myModel onSubmit="SubmitForm"></InputWizard>
|
||||
<InputWizard Data=@myModel OnSubmit="SubmitForm"></InputWizard>
|
||||
</div>
|
||||
@code {
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Aycode.Blazor\AyCode.Blazor.Components\AyCode.Blazor.Components.csproj" />
|
||||
<ProjectReference Include="..\..\Aycode.Blazor\AyCode.Blazor.Models\AyCode.Blazor.Models.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Models\TIAM.Models.csproj" />
|
||||
<ProjectReference Include="..\TIAMResources\TIAM.Resources.csproj" />
|
||||
<ProjectReference Include="..\TIAMWebApp\Shared\TIAMWebApp.Shared.Application.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
@ -34,6 +36,15 @@
|
|||
<Reference Include="AyCode.Interfaces">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Interfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Models">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Services">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Services.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Utils">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Utils.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ using TIAMWebApp.Shared.Application.Models.PageModels;
|
|||
using TIAMWebApp.Shared.Application.Utility;
|
||||
using AyCode.Interfaces.StorageHandlers;
|
||||
using AyCode.Core.Logger;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
|
||||
|
||||
namespace TIAMWebApp.Client.Services
|
||||
|
|
@ -37,26 +38,26 @@ namespace TIAMWebApp.Client.Services
|
|||
|
||||
public async Task<UserSessionModel> IsLoggedInAsync(Guid id)
|
||||
{
|
||||
UserSessionModel User = null;
|
||||
UserSessionModel user = null;
|
||||
//api call to get user
|
||||
var dbUser = await GetUserByIdAsync(id);
|
||||
var userModelDto = await GetUserByIdAsync(id);
|
||||
|
||||
if (dbUser != null)
|
||||
if (userModelDto != null)
|
||||
{
|
||||
var a = dbUser.UserProductMappings.FirstOrDefault().Product;
|
||||
var a = userModelDto.UserProductMappings.FirstOrDefault()?.Product;
|
||||
|
||||
if (a != null)
|
||||
logToBrowserConsole.LogToBC($"{a.Name}");
|
||||
|
||||
//get user's properties
|
||||
var hasProperties = await serviceProviderDataService.GetPropertiesByOwnerIdAsync(dbUser.Id);
|
||||
var hasProperties = await serviceProviderDataService.GetPropertiesByOwnerIdAsync(userModelDto.Id);
|
||||
|
||||
if (hasProperties != null)
|
||||
logToBrowserConsole.LogToBC($"{hasProperties.Count} properties found");
|
||||
|
||||
//create user session model
|
||||
User = new UserSessionModel(dbUser.Id, UserType.User, dbUser.EmailAddress, hasProperties, 1);
|
||||
return User;
|
||||
user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto.Profile?.Name, hasProperties, 1);
|
||||
return user;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -130,24 +131,24 @@ namespace TIAMWebApp.Client.Services
|
|||
return (isSuccess, result);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<User>?> GetUsersAsync()
|
||||
public async Task<IEnumerable<UserModelDto>?> GetUsersAsync()
|
||||
{
|
||||
return await http.GetFromJsonAsync<IEnumerable<User>>(APIUrls.GetUsers);
|
||||
return await http.GetFromJsonAsync<IEnumerable<UserModelDto>>(APIUrls.GetUsers);
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserByEmailAsync(string email)
|
||||
public async Task<UserModelDto?> GetUserByEmailAsync(string email)
|
||||
{
|
||||
var url = $"{Setting.BaseUrl}/{APIUrls.GetUserByEmail}";
|
||||
return await http.GetFromJsonAsync<User?>(url);
|
||||
return await http.GetFromJsonAsync<UserModelDto?>(url);
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserByIdAsync(Guid Id)
|
||||
public async Task<UserModelDto?> GetUserByIdAsync(Guid id)
|
||||
{
|
||||
var url = $"{Setting.BaseUrl}/{APIUrls.GetUserById}";
|
||||
logToBrowserConsole.LogToBC("GetUserByIdAsync url: " + url + ", " + Id.ToString());
|
||||
var response = await http.PostAsJsonAsync(url, Id);
|
||||
logToBrowserConsole.LogToBC("GetUserByIdAsync url: " + url + ", " + id.ToString());
|
||||
var response = await http.PostAsJsonAsync(url, id);
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
var user = JsonConvert.DeserializeObject<User>(result);
|
||||
var user = JsonConvert.DeserializeObject<UserModelDto>(result);
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using TIAM.Database.DataLayers.Users;
|
||||
using AyCode.Utils.Helpers;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using TIAMWebApp.Server.ModelsTIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Utility;
|
||||
|
||||
|
|
@ -322,34 +323,33 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route("GetUsers")]
|
||||
public Task<List<User>> GetUsers()
|
||||
public Task<List<UserModelDto>> GetUsers()
|
||||
{
|
||||
//var users = await _userDal.Ctx.Users.ToListAsync();//.GetUsersAsync();
|
||||
//return users;
|
||||
return _userDal.GetUsersAsync();
|
||||
return _userDal.GetAllUsersModelDtoAsync();
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route("GetUserByEmail")]
|
||||
public async Task<User?> GetUserByEmail(string email)
|
||||
public Task<UserModelDto?> GetUserByEmail(string email)
|
||||
{
|
||||
return await _userDal.GetUserByEmailAsync(email);
|
||||
return _userDal.GetUserModelDtoByEmailAsync(email);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route("GetUserById")]
|
||||
public User? GetUserById([FromBody] Guid id)
|
||||
public Task<UserModelDto?> GetUserById([FromBody] Guid id)
|
||||
{
|
||||
Logger.Info($"GetUserById called with id: {id}");
|
||||
var result = _userDal.GetUserById(id);
|
||||
var b = result.UserProductMappings.FirstOrDefault(x => x.Id != null);
|
||||
var result = _userDal.GetUserModelDtoByIdAsync(id);
|
||||
|
||||
var a = JsonSerializer.Serialize(result);
|
||||
//var b = result.UserProductMappings.FirstOrDefault(x => x.Id != null);
|
||||
//var a = JsonSerializer.Serialize(result);
|
||||
//Console.WriteLine($"GetUserById result: {a}");
|
||||
|
||||
|
||||
Console.WriteLine($"GetUserById result: {a}");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using TIAM.Database.DataLayers.ServiceProviders;
|
|||
using TIAM.Database.DataLayers.Users;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Products.DTOs;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||
|
||||
|
|
@ -21,8 +22,8 @@ namespace TIAMWebApp.Shared.Application.Interfaces
|
|||
|
||||
//public Task<Dictionary<int, string>> GetUserRolesAsync(UserModel userModel);
|
||||
|
||||
public Task<IEnumerable<User>?> GetUsersAsync();
|
||||
public Task<User?> GetUserByEmailAsync(string email);
|
||||
public Task<IEnumerable<UserModelDto>?> GetUsersAsync();
|
||||
public Task<UserModelDto?> GetUserByEmailAsync(string email);
|
||||
Task<bool> RefreshToken();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAMWebApp.Shared.Application.Models
|
||||
|
|
@ -7,17 +8,18 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
{
|
||||
public Guid UserId { get; set; }
|
||||
public UserType UserType { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string? UserName { get; set; }
|
||||
public string DisplayName => string.IsNullOrWhiteSpace(UserName) ? UserId.ToString() : UserName;
|
||||
|
||||
public Dictionary<Guid, string>? HasProperties { get; set; }
|
||||
public int UserRoles { get; set; }
|
||||
public Dictionary<int, string> UserRolesDictionary { get; set; }
|
||||
|
||||
public UserSessionModel(Guid userId, UserType userType, string email, Dictionary<Guid, string>? hasProperties, int userRoles)
|
||||
public UserSessionModel(Guid userId, UserType userType, string? userName, Dictionary<Guid, string>? hasProperties, int userRoles)
|
||||
{
|
||||
UserId = userId;
|
||||
UserType = userType;
|
||||
Email = email;
|
||||
UserName = userName;
|
||||
HasProperties = hasProperties;
|
||||
//UserRoles = userRoles;
|
||||
//UserRolesDictionary = new Dictionary<int, string>();
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
<ProjectReference Include="..\..\TIAM.Database\TIAM.Database.csproj" />
|
||||
<ProjectReference Include="..\..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" />
|
||||
<ProjectReference Include="..\..\TIAM.Entities\TIAM.Entities.csproj" />
|
||||
<ProjectReference Include="..\..\TIAM.Models\TIAM.Models.csproj" />
|
||||
<ProjectReference Include="..\..\TIAMResources\TIAM.Resources.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AyCode.Blazor.Models", "..\
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AyCode.Blazor.Models.Server", "..\Aycode.Blazor\AyCode.Blazor.Models.Server\AyCode.Blazor.Models.Server.csproj", "{A36322E8-F485-455E-84AA-B911948B6702}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TIAM.Resources", "TIAMResources\TIAM.Resources.csproj", "{2A300982-AA2E-4E62-97F2-6EF4C97939B2}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Models", "TIAM.Models\TIAM.Models.csproj", "{6037FF79-88D2-457C-BA3A-9AC978873741}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Resources", "TIAMResources\TIAM.Resources.csproj", "{2A300982-AA2E-4E62-97F2-6EF4C97939B2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -103,6 +105,10 @@ Global
|
|||
{A36322E8-F485-455E-84AA-B911948B6702}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A36322E8-F485-455E-84AA-B911948B6702}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A36322E8-F485-455E-84AA-B911948B6702}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6037FF79-88D2-457C-BA3A-9AC978873741}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6037FF79-88D2-457C-BA3A-9AC978873741}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6037FF79-88D2-457C-BA3A-9AC978873741}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6037FF79-88D2-457C-BA3A-9AC978873741}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2A300982-AA2E-4E62-97F2-6EF4C97939B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2A300982-AA2E-4E62-97F2-6EF4C97939B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2A300982-AA2E-4E62-97F2-6EF4C97939B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
|
|||
Loading…
Reference in New Issue