68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using AyCode.Interfaces.Entities;
|
|
using AyCode.Interfaces.TimeStampInfo;
|
|
using Newtonsoft.Json;
|
|
using TIAM.Entities.Drivers;
|
|
using TIAM.Entities.Products;
|
|
|
|
namespace TIAM.Entities.Users;
|
|
|
|
[Table("UserProductMapping")]
|
|
public class UserProductMapping : IEntityGuid, IUserRelation, IProductRelation, ITimeStampInfo
|
|
{
|
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public Guid Id { get; set; }
|
|
public Guid UserId { get; set; }
|
|
public Guid ProductId { get; set; }
|
|
|
|
public virtual User User { get; set; }
|
|
public virtual Product Product { get; set; }
|
|
//public virtual List<Transfer>? Transfers { get; set; }
|
|
|
|
public double? DriverBalance { get; set; }
|
|
|
|
public int Permissions { get; set; } = 1;
|
|
public bool IsAdmin { get; set; }
|
|
|
|
//[JsonIgnore]
|
|
//private string? JsonDetails { get; set; }
|
|
|
|
//[Column("JsonDetailModel")]
|
|
[NotMapped]
|
|
[JsonIgnore]
|
|
[System.Text.Json.Serialization.JsonIgnore]
|
|
public UserProductJsonDetailModel? JsonDetailModel { get; set; } = null;
|
|
|
|
public DateTime Created { get; set; }
|
|
public DateTime Modified { get; set; }
|
|
|
|
public UserProductMapping()
|
|
{ }
|
|
|
|
public UserProductMapping(UserProductMapping upm) : this(upm.Id, upm.UserId, upm.ProductId, upm.Permissions, upm.JsonDetailModel)
|
|
{
|
|
IsAdmin = upm.IsAdmin;
|
|
Created = upm.Created;
|
|
Modified = upm.Modified;
|
|
}
|
|
|
|
public UserProductMapping(Guid userId, Guid productId) : this(Guid.NewGuid(), userId, productId)
|
|
{ }
|
|
|
|
public UserProductMapping(Guid id, Guid userId, Guid productId) : this(id, userId, productId, 1)
|
|
{ }
|
|
|
|
public UserProductMapping(Guid id, Guid userId, Guid productId, int permissions) : this(id, userId, productId, permissions, null)
|
|
{ }
|
|
|
|
public UserProductMapping(Guid id, Guid userId, Guid productId, int permissions, UserProductJsonDetailModel? toJsonDetailModel) : this()
|
|
{
|
|
Id = id;
|
|
UserId = userId;
|
|
ProductId = productId;
|
|
|
|
Permissions = permissions;
|
|
JsonDetailModel = toJsonDetailModel;
|
|
}
|
|
} |