Compare commits
No commits in common. "733fdd24847c5c97b4ee7ad6f3b8fa7b11eb955d" and "f9ea3f400111c3eed852a9e766810a34d27d809e" have entirely different histories.
733fdd2484
...
f9ea3f4001
|
|
@ -5,7 +5,6 @@ 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;
|
||||
|
|
@ -98,35 +97,11 @@ namespace TIAM.Database.Test
|
|||
public void GetUserProductMappingById_ReturnsUserProductMapping_WherHasUserAndProductRelation(string userProductMappingIdString)
|
||||
{
|
||||
var userProductMappingId = Guid.Parse(userProductMappingIdString);
|
||||
var userProductMapping = Dal.GetUserProductMappingById(userProductMappingId, true);
|
||||
var userProductMapping = Dal.GetUserProductMappingById(userProductMappingId);
|
||||
|
||||
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,15 +10,12 @@ 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, Profile, UserToken>
|
||||
public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, UserToken>
|
||||
{
|
||||
private Mock<UserDbContext> _mockContext;
|
||||
|
||||
|
|
@ -54,27 +51,23 @@ namespace TIAM.Database.Test
|
|||
|
||||
[TestMethod]
|
||||
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
|
||||
public async Task SerializeUserModelDto_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
|
||||
public void SerializeUser_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 userModel = await Dal.GetUserModelDtoByIdAsync(userId).ConfigureAwait(false);
|
||||
var serializedUser = JsonConvert.SerializeObject(user, options);
|
||||
user = JsonConvert.DeserializeObject<User>(serializedUser);
|
||||
|
||||
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);
|
||||
Assert.IsNotNull(user);
|
||||
Assert.IsNotNull(user.UserProductMappings);
|
||||
//Assert.IsNotNull(user.UserProductMappings.FirstOrDefault()?.Product);
|
||||
}
|
||||
|
||||
//[TestMethod]
|
||||
|
|
|
|||
|
|
@ -8,15 +8,14 @@ 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
|
||||
|
|
@ -32,13 +31,9 @@ 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 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));
|
||||
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId) => Session(x => x.GetUserProductMappingById(userProductMappingId));
|
||||
|
||||
#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,18 +5,14 @@ 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, Profile, UserToken>
|
||||
public class UserDal : AcUserDalBase<UserDbContext, User, UserToken>
|
||||
{
|
||||
|
||||
public UserDal() : base()
|
||||
|
|
@ -32,9 +28,14 @@ namespace TIAM.Database.DataLayers.Users
|
|||
return Context.Users.ToListAsync();
|
||||
}
|
||||
|
||||
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?> 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<User?> GetUserByPhoneNumberAsync(string phoneNumber)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace TIAM.Database.DbContexts
|
|||
{
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
|
||||
optionsBuilder.UseLazyLoadingProxies(true);
|
||||
optionsBuilder.UseLazyLoadingProxies(false);
|
||||
optionsBuilder.EnableDetailedErrors(true);
|
||||
|
||||
//optionsBuilder.UseSqlServer(Configuration.GetConnectionString("DeveloperDbConnection"));
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
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, Profile, UserToken>, IUserDbSet
|
||||
public interface IUserDbContext : IAcUserDbContextBase<User, UserToken>
|
||||
{
|
||||
}
|
||||
|
|
@ -11,10 +11,8 @@ 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
|
||||
|
|
@ -53,9 +51,7 @@ namespace TIAM.Database.DbContexts.Users
|
|||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>());
|
||||
|
||||
modelBuilder.Entity<Product>().BuildProductToServiceProviderRelation();
|
||||
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
||||
new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
using AyCode.Database.DbSets.Users;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.DbSets.Users;
|
||||
|
||||
public interface IUserDbSet : IAcUserDbSet<User, Profile>
|
||||
public interface IUserDbSet : IAcUserDbSet<User>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
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;
|
||||
|
||||
|
|
@ -15,19 +13,16 @@ 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, bool autoInclude = true)
|
||||
=> ctx.UserProductMappingsWithRelations(autoInclude).FirstOrDefault(x => x.Id == userProductMappingId);
|
||||
public static UserProductMapping? GetUserProductMappingById(this IUserProductMappingDbSet ctx, Guid userProductMappingId)
|
||||
=> ctx.UserProductMappingsWithRelations().FirstOrDefault(x => x.Id == userProductMappingId);
|
||||
|
||||
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 UserProductMapping? GetUserProductMapping(this IUserProductMappingDbSet ctx, Guid userId, Guid productId)
|
||||
=> ctx.UserProductMappingsWithRelations().FirstOrDefault(x => x.UserId == userId && x.ProductId == productId);
|
||||
|
||||
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> GetUserProductMappingsByUserId(this IUserProductMappingDbSet ctx, Guid userId)
|
||||
=> ctx.UserProductMappingsWithRelations().Where(x => x.UserId == userId);
|
||||
|
||||
public static IQueryable<UserProductMapping> GetUserProductMappingsByProductId(this IUserProductMappingDbSet ctx, Guid productId, bool autoInclude = true)
|
||||
=> ctx.UserProductMappingsWithRelations(autoInclude).Where(x => x.ProductId == productId);
|
||||
public static IQueryable<UserProductMapping> GetUserProductMappingsByProductId(this IUserProductMappingDbSet ctx, Guid productId)
|
||||
=> ctx.UserProductMappingsWithRelations().Where(x => x.ProductId == productId);
|
||||
}
|
||||
|
|
@ -12,16 +12,10 @@ public static class ProductEntityTypeBuilderExtensions
|
|||
public static void BuildProductToUserProductMappingRelation(this EntityTypeBuilder<Product> modelBuilder, bool autoInclude = true)
|
||||
{
|
||||
modelBuilder
|
||||
.HasMany(e => e.Users)
|
||||
.WithMany(e => e.Products)
|
||||
.UsingEntity<UserProductMapping>();
|
||||
|
||||
//modelBuilder
|
||||
// .HasMany(e => e.UserProductMappings)
|
||||
// .WithOne(e => e.Product).HasForeignKey(x => x.ProductId);
|
||||
.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,7 +2,6 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.Numerics;
|
||||
using AyCode.Interfaces.Profiles;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
|
|
@ -14,20 +13,17 @@ 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>();
|
||||
//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);
|
||||
// .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);
|
||||
|
||||
modelBuilder.Navigation(e => e.Products).AutoInclude(autoInclude);
|
||||
modelBuilder.Navigation(e => e.UserProductMappings).AutoInclude(autoInclude);
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +65,7 @@ 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
|
||||
public static void BuildUserToServiceProviderRelation<TUser>(this EntityTypeBuilder<TUser> modelBuilder) where TUser : class, IUserBase
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
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;
|
||||
|
|
@ -22,6 +21,6 @@ public class UserEntityTypeDefaultConfiguration : IAcEntityTypeConfiguration<Use
|
|||
//base.Configure(builder);
|
||||
|
||||
builder.BuildUserToUserProductMappingRelation();
|
||||
builder.BuildUserToServiceProviderRelation<User, Profile>();
|
||||
builder.BuildUserToServiceProviderRelation();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
<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,14 +14,12 @@ 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, 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)
|
||||
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)
|
||||
{
|
||||
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, string name, string description, float price, string jsonDetails)
|
||||
protected ProductBase(Guid id, ProductType type, Guid userMediaId, string name, string description, float price, string jsonDetails)
|
||||
{
|
||||
Id = id;
|
||||
ProductType = type;
|
||||
//UserMediaId = userMediaId;
|
||||
UserMediaId = userMediaId;
|
||||
Name = name;
|
||||
Description = description;
|
||||
Price = price;
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
using AyCode.Interfaces.Profiles;
|
||||
|
||||
namespace TIAM.Entities.Profiles;
|
||||
|
||||
public interface IProfile : IAcProfileBase, IProfileDto
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
using AyCode.Interfaces.Profiles.Dtos;
|
||||
|
||||
namespace TIAM.Entities.Profiles;
|
||||
|
||||
public interface IProfileDto : IAcProfileDtoBase
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
using AyCode.Entities.Profiles;
|
||||
|
||||
namespace TIAM.Entities.Profiles;
|
||||
|
||||
public class Profile : AcProfileBase, IProfile
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
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; }
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
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,16 +6,15 @@ 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<Profile>, IUser
|
||||
public class User : UserBase
|
||||
{
|
||||
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; } = new();
|
||||
public virtual List<UserProductMapping> UserProductMappings { get; set; } = new();
|
||||
|
||||
public User() { }
|
||||
public User(string email, string password) : this(Guid.NewGuid(), email, password) { }
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
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; }
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
using AyCode.Interfaces.Users.Dtos;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Models.Dtos.Users;
|
||||
|
||||
public class UserDto : IUserDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
<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,7 +3,6 @@ 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;
|
||||
|
|
@ -50,7 +49,7 @@ namespace TIAMMobileApp.Services
|
|||
{
|
||||
|
||||
var hasProperties = await _serviceProviderDataService.GetPropertiesByOwnerIdAsync(dbUser.Id);
|
||||
var user = new UserSessionModel(dbUser.Id, UserType.User, dbUser.Profile?.Name, hasProperties, 1);
|
||||
var user = new UserSessionModel(dbUser.Id, UserType.User, dbUser.EmailAddress, hasProperties, 1);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
|
@ -118,14 +117,14 @@ namespace TIAMMobileApp.Services
|
|||
return (isSuccess, result);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<UserModelDto>?> GetUsersAsync()
|
||||
public async Task<IEnumerable<User>?> GetUsersAsync()
|
||||
{
|
||||
return await http.GetFromJsonAsync<IEnumerable<UserModelDto>>(APIUrls.GetUsers);
|
||||
return await http.GetFromJsonAsync<IEnumerable<User>>(APIUrls.GetUsers);
|
||||
}
|
||||
|
||||
public async Task<UserModelDto?> GetUserByEmailAsync(string email)
|
||||
public async Task<User?> GetUserByEmailAsync(string email)
|
||||
{
|
||||
return await http.GetFromJsonAsync<UserModelDto?>(APIUrls.GetUserByEmail);
|
||||
return await http.GetFromJsonAsync<User?>(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.DisplayName}, setting autenthicated state");
|
||||
logToBrowserConsole.LogToBC($"Saved user in db is: {user.Email}, setting autenthicated state");
|
||||
sessionService.IsAuthenticated = true;
|
||||
NavManager.NavigateTo("/index");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Email = sessionService.User.DisplayName;
|
||||
Email = sessionService.User.Email;
|
||||
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]
|
||||
public required LogToBrowserConsole LogToBrowserConsole { get; set; }
|
||||
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 = "(999)000-0000";
|
||||
string _formSubmitResult = "";
|
||||
private string _spinnerClass = "";
|
||||
string PhoneMask { get; set; } = "(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<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<System.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<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<System.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<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.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<DateTime>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "DateChanged", EventCallback.Factory.Create<System.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<double>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.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<int>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.Int32>(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<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
|
|
@ -211,8 +211,6 @@ namespace TIAMSharedUI.Pages.Components
|
|||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
case DataType.MultilineText:
|
||||
{
|
||||
|
|
@ -220,7 +218,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<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
|
||||
|
|
@ -260,14 +258,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 +279,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.DisplayName;
|
||||
Email = sessionService.User.Email;
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
@using AyCode.Utils.Extensions
|
||||
@if (Users == null)
|
||||
@if (Users == null)
|
||||
{
|
||||
<p>
|
||||
<em>Loading ...</em>
|
||||
|
|
@ -12,9 +11,7 @@ else
|
|||
|
||||
@foreach (var dest in Users)
|
||||
{
|
||||
<p>
|
||||
@(dest.Profile == null ? dest.UserDto.Id.ToString() : dest.Profile.Name)
|
||||
</p>
|
||||
<p>@dest.EmailAddress</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ 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;
|
||||
|
||||
|
|
@ -20,7 +19,7 @@ namespace TIAMSharedUI.Pages
|
|||
get;
|
||||
set;
|
||||
}
|
||||
public required List<UserModelDto> Users
|
||||
public List<TIAM.Entities.Users.User>? 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,8 +20,6 @@
|
|||
<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>
|
||||
|
|
@ -36,15 +34,6 @@
|
|||
<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,7 +12,6 @@ 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
|
||||
|
|
@ -38,26 +37,26 @@ namespace TIAMWebApp.Client.Services
|
|||
|
||||
public async Task<UserSessionModel> IsLoggedInAsync(Guid id)
|
||||
{
|
||||
UserSessionModel user = null;
|
||||
UserSessionModel User = null;
|
||||
//api call to get user
|
||||
var userModelDto = await GetUserByIdAsync(id);
|
||||
var dbUser = await GetUserByIdAsync(id);
|
||||
|
||||
if (userModelDto != null)
|
||||
if (dbUser != null)
|
||||
{
|
||||
var a = userModelDto.UserProductMappings.FirstOrDefault()?.Product;
|
||||
var a = dbUser.UserProductMappings.FirstOrDefault().Product;
|
||||
|
||||
if (a != null)
|
||||
logToBrowserConsole.LogToBC($"{a.Name}");
|
||||
|
||||
//get user's properties
|
||||
var hasProperties = await serviceProviderDataService.GetPropertiesByOwnerIdAsync(userModelDto.Id);
|
||||
var hasProperties = await serviceProviderDataService.GetPropertiesByOwnerIdAsync(dbUser.Id);
|
||||
|
||||
if (hasProperties != null)
|
||||
logToBrowserConsole.LogToBC($"{hasProperties.Count} properties found");
|
||||
|
||||
//create user session model
|
||||
user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto.Profile?.Name, hasProperties, 1);
|
||||
return user;
|
||||
User = new UserSessionModel(dbUser.Id, UserType.User, dbUser.EmailAddress, hasProperties, 1);
|
||||
return User;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -131,24 +130,24 @@ namespace TIAMWebApp.Client.Services
|
|||
return (isSuccess, result);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<UserModelDto>?> GetUsersAsync()
|
||||
public async Task<IEnumerable<User>?> GetUsersAsync()
|
||||
{
|
||||
return await http.GetFromJsonAsync<IEnumerable<UserModelDto>>(APIUrls.GetUsers);
|
||||
return await http.GetFromJsonAsync<IEnumerable<User>>(APIUrls.GetUsers);
|
||||
}
|
||||
|
||||
public async Task<UserModelDto?> GetUserByEmailAsync(string email)
|
||||
public async Task<User?> GetUserByEmailAsync(string email)
|
||||
{
|
||||
var url = $"{Setting.BaseUrl}/{APIUrls.GetUserByEmail}";
|
||||
return await http.GetFromJsonAsync<UserModelDto?>(url);
|
||||
return await http.GetFromJsonAsync<User?>(url);
|
||||
}
|
||||
|
||||
public async Task<UserModelDto?> GetUserByIdAsync(Guid id)
|
||||
public async Task<User?> 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<UserModelDto>(result);
|
||||
var user = JsonConvert.DeserializeObject<User>(result);
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ 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;
|
||||
|
||||
|
|
@ -323,33 +322,34 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route("GetUsers")]
|
||||
public Task<List<UserModelDto>> GetUsers()
|
||||
public Task<List<User>> GetUsers()
|
||||
{
|
||||
//var users = await _userDal.Ctx.Users.ToListAsync();//.GetUsersAsync();
|
||||
//return users;
|
||||
return _userDal.GetAllUsersModelDtoAsync();
|
||||
return _userDal.GetUsersAsync();
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route("GetUserByEmail")]
|
||||
public Task<UserModelDto?> GetUserByEmail(string email)
|
||||
public async Task<User?> GetUserByEmail(string email)
|
||||
{
|
||||
return _userDal.GetUserModelDtoByEmailAsync(email);
|
||||
return await _userDal.GetUserByEmailAsync(email);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route("GetUserById")]
|
||||
public Task<UserModelDto?> GetUserById([FromBody] Guid id)
|
||||
public User? GetUserById([FromBody] Guid id)
|
||||
{
|
||||
Logger.Info($"GetUserById called with id: {id}");
|
||||
var result = _userDal.GetUserModelDtoByIdAsync(id);
|
||||
var result = _userDal.GetUserById(id);
|
||||
var b = result.UserProductMappings.FirstOrDefault(x => x.Id != null);
|
||||
|
||||
//var b = result.UserProductMappings.FirstOrDefault(x => x.Id != null);
|
||||
//var a = JsonSerializer.Serialize(result);
|
||||
//Console.WriteLine($"GetUserById result: {a}");
|
||||
var a = JsonSerializer.Serialize(result);
|
||||
|
||||
|
||||
Console.WriteLine($"GetUserById result: {a}");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ 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,7 +4,6 @@ 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;
|
||||
|
||||
|
|
@ -22,8 +21,8 @@ namespace TIAMWebApp.Shared.Application.Interfaces
|
|||
|
||||
//public Task<Dictionary<int, string>> GetUserRolesAsync(UserModel userModel);
|
||||
|
||||
public Task<IEnumerable<UserModelDto>?> GetUsersAsync();
|
||||
public Task<UserModelDto?> GetUserByEmailAsync(string email);
|
||||
public Task<IEnumerable<User>?> GetUsersAsync();
|
||||
public Task<User?> GetUserByEmailAsync(string email);
|
||||
Task<bool> RefreshToken();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAMWebApp.Shared.Application.Models
|
||||
|
|
@ -8,18 +7,17 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
{
|
||||
public Guid UserId { get; set; }
|
||||
public UserType UserType { get; set; }
|
||||
public string? UserName { get; set; }
|
||||
public string DisplayName => string.IsNullOrWhiteSpace(UserName) ? UserId.ToString() : UserName;
|
||||
public string Email { get; set; }
|
||||
|
||||
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? userName, Dictionary<Guid, string>? hasProperties, int userRoles)
|
||||
public UserSessionModel(Guid userId, UserType userType, string email, Dictionary<Guid, string>? hasProperties, int userRoles)
|
||||
{
|
||||
UserId = userId;
|
||||
UserType = userType;
|
||||
UserName = userName;
|
||||
Email = email;
|
||||
HasProperties = hasProperties;
|
||||
//UserRoles = userRoles;
|
||||
//UserRolesDictionary = new Dictionary<int, string>();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
<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,9 +33,7 @@ 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("{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}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TIAM.Resources", "TIAMResources\TIAM.Resources.csproj", "{2A300982-AA2E-4E62-97F2-6EF4C97939B2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -105,10 +103,6 @@ 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