json serialize check
This commit is contained in:
parent
03d30fe11a
commit
f44f4d794d
|
|
@ -1,7 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AyCode.Entities.Users;
|
using AyCode.Entities.Users;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
|
|
@ -13,8 +15,11 @@ namespace TIAM.Entities.Users
|
||||||
//public virtual List<Product> Products { get; } = new();
|
//public virtual List<Product> Products { get; } = new();
|
||||||
|
|
||||||
//public virtual ServiceProvider ServiceProvider { get; set; } = new();
|
//public virtual ServiceProvider ServiceProvider { get; set; } = new();
|
||||||
|
|
||||||
|
//[NotMapped]
|
||||||
public virtual List<UserProductMapping> UserProductMappings { get; } = new();
|
public virtual List<UserProductMapping> UserProductMappings { get; } = new();
|
||||||
|
|
||||||
|
|
||||||
public User() { }
|
public User() { }
|
||||||
public User(string email, string password) : this(Guid.NewGuid(), email, password) { }
|
public User(string email, string password) : this(Guid.NewGuid(), email, password) { }
|
||||||
public User(Guid id, string email, string password) : base(id, email, password)
|
public User(Guid id, string email, string password) : base(id, email, password)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using AyCode.Interfaces.Entities;
|
using AyCode.Interfaces.Entities;
|
||||||
using AyCode.Interfaces.TimeStampInfo;
|
using AyCode.Interfaces.TimeStampInfo;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
|
|
@ -14,7 +15,9 @@ public class UserProductMapping : IEntityGuid, ITimeStampInfo
|
||||||
public Guid UserId { get; set; }
|
public Guid UserId { get; set; }
|
||||||
public Guid ProductId { get; set; }
|
public Guid ProductId { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public virtual User User { get; set; }
|
public virtual User User { get; set; }
|
||||||
|
[JsonIgnore]
|
||||||
public virtual Product Product { get; set; }
|
public virtual Product Product { get; set; }
|
||||||
|
|
||||||
public DateTime Created { get; set; }
|
public DateTime Created { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -340,11 +340,17 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("GetUserById")]
|
[Route("GetUserById")]
|
||||||
public async Task<User?> GetUserById([FromBody] Guid id)
|
public User? GetUserById([FromBody] Guid id)
|
||||||
{
|
{
|
||||||
Logger.Info($"GetUserById called with id: {id}");
|
Logger.Info($"GetUserById called with id: {id}");
|
||||||
|
var result = _userDal.GetUserById(id);
|
||||||
|
var b = result.UserProductMappings.FirstOrDefault(x => x.Id != null);
|
||||||
|
|
||||||
return await _userDal.GetUserByIdAsync(id);
|
var a = JsonSerializer.Serialize(result);
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine($"GetUserById result: {a}");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool VerifyPassword(string password, string hashedPassword)
|
private bool VerifyPassword(string password, string hashedPassword)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue