73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using AyCode.Interfaces.Profiles.Dtos;
|
|
using AyCode.Interfaces.ServiceProviders;
|
|
using AyCode.Interfaces.Users;
|
|
using AyCode.Utils.Extensions;
|
|
|
|
namespace AyCode.Entities.ServiceProviders
|
|
{
|
|
[Table("ServiceProviders")]
|
|
public abstract class AcCompany<TUser, TUserToServiceProvider, TProfile> : IAcCompany<TUser, TUserToServiceProvider, TProfile>
|
|
where TUser : class, IAcUserBase
|
|
where TUserToServiceProvider : class, IAcUserToCompanyBase
|
|
where TProfile : class, IAcProfileDtoBase
|
|
{
|
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
|
public Guid Id { get; set; }
|
|
|
|
[Required]
|
|
public Guid OwnerId { get; set; }
|
|
|
|
public Guid ProfileId { get; set; }
|
|
public virtual TProfile Profile { get; set; }
|
|
|
|
[Required]
|
|
public string Name { get; set; }
|
|
|
|
public double? CommissionPercent { get; set; }
|
|
|
|
[Required]
|
|
public Guid AffiliateId { get; set; }
|
|
public Guid? ReferralId { get; set; }
|
|
|
|
public virtual List<TUser> Users { get; set; }
|
|
public virtual List<TUserToServiceProvider> UserToServiceProviders { get; set; }
|
|
|
|
public DateTime Created { get; set; }
|
|
public DateTime Modified { get; set; }
|
|
|
|
|
|
protected AcCompany()
|
|
{
|
|
}
|
|
|
|
protected AcCompany(string name, Guid ownerId) : this(Guid.NewGuid(), name, ownerId)
|
|
{
|
|
}
|
|
|
|
protected AcCompany(Guid id, string name, Guid ownerId) : this(id, name, ownerId, Guid.NewGuid())
|
|
{
|
|
}
|
|
|
|
protected AcCompany(Guid id, string name, Guid ownerId, Guid affiliateId, double? commissionPercent = null) : this()
|
|
{
|
|
Id = id;
|
|
Name = name;
|
|
OwnerId = ownerId;
|
|
|
|
AffiliateId = affiliateId;
|
|
CommissionPercent = commissionPercent;
|
|
}
|
|
|
|
public void SetProfile(TProfile profile)
|
|
{
|
|
if (profile.Id.IsNullOrEmpty()) profile.Id = Guid.NewGuid();
|
|
|
|
Profile = profile;
|
|
ProfileId = profile.Id;
|
|
}
|
|
}
|
|
}
|