server cleanup
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Shared\Baya.SharedKernel\Baya.SharedKernel.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,59 @@
|
||||
namespace Baya.Domain.Common;
|
||||
|
||||
public interface IEntity
|
||||
{
|
||||
}
|
||||
|
||||
public interface ITimeModification
|
||||
{
|
||||
DateTime CreatedTime { get; set; }
|
||||
DateTime? ModifiedDate { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseEntity<TKey> : IEntity, ITimeModification
|
||||
{
|
||||
public TKey Id { get; protected set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is BaseEntity<TKey> other))
|
||||
return false;
|
||||
|
||||
if (ReferenceEquals(this, other))
|
||||
return true;
|
||||
|
||||
if (GetType() != other.GetType())
|
||||
return false;
|
||||
|
||||
return Id.Equals(other.Id);
|
||||
}
|
||||
|
||||
public static bool operator ==(BaseEntity<TKey> a, BaseEntity<TKey> b)
|
||||
{
|
||||
if (a is null && b is null)
|
||||
return true;
|
||||
|
||||
if (a is null || b is null)
|
||||
return false;
|
||||
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
public static bool operator !=(BaseEntity<TKey> a, BaseEntity<TKey> b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (GetType().ToString() + Id).GetHashCode();
|
||||
}
|
||||
|
||||
public DateTime CreatedTime { get; set; }
|
||||
public DateTime? ModifiedDate { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseEntity : BaseEntity<int>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Baya.Domain.Common;
|
||||
|
||||
namespace Baya.Domain.Entities.Order;
|
||||
|
||||
public class Order:BaseEntity
|
||||
{
|
||||
public string OrderName { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
#region Navigation Properties
|
||||
|
||||
public User.User User { get; set; }
|
||||
public int UserId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Baya.Domain.Common;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Baya.Domain.Entities.User;
|
||||
|
||||
public class Role:IdentityRole<int>,IEntity
|
||||
{
|
||||
public Role()
|
||||
{
|
||||
CreatedDate=DateTime.Now;
|
||||
}
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
public DateTime CreatedDate { get; set; }
|
||||
public ICollection<RoleClaim> Claims { get; set; }
|
||||
public ICollection<UserRole> Users { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Baya.Domain.Common;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Baya.Domain.Entities.User;
|
||||
|
||||
public class RoleClaim:IdentityRoleClaim<int>,IEntity
|
||||
{
|
||||
public RoleClaim()
|
||||
{
|
||||
CreatedClaim=DateTime.Now;
|
||||
}
|
||||
|
||||
public DateTime CreatedClaim { get; set; }
|
||||
public Role Role { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Baya.Domain.Common;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Baya.Domain.Entities.User;
|
||||
|
||||
public class User:IdentityUser<int>,IEntity
|
||||
{
|
||||
public User()
|
||||
{
|
||||
this.GeneratedCode = Guid.NewGuid().ToString().Substring(0, 8);
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string FamilyName { get; set; }
|
||||
public string GeneratedCode { get; set; }
|
||||
|
||||
public ICollection<UserRole> UserRoles { get; set; }
|
||||
public ICollection<UserLogin> Logins { get; set; }
|
||||
public ICollection<UserClaim> Claims { get; set; }
|
||||
public ICollection<UserToken> Tokens { get; set; }
|
||||
public ICollection<UserRefreshToken> UserRefreshTokens { get; set; }
|
||||
|
||||
#region Navigation Properties
|
||||
|
||||
public IList<Order.Order> Orders { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Baya.Domain.Common;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Baya.Domain.Entities.User;
|
||||
|
||||
public class UserClaim:IdentityUserClaim<int>,IEntity
|
||||
{
|
||||
public User User { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Baya.Domain.Common;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Baya.Domain.Entities.User;
|
||||
|
||||
public class UserLogin:IdentityUserLogin<int>,IEntity
|
||||
{
|
||||
public UserLogin()
|
||||
{
|
||||
LoggedOn=DateTime.Now;
|
||||
}
|
||||
|
||||
public User User { get; set; }
|
||||
public DateTime LoggedOn { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Baya.Domain.Common;
|
||||
|
||||
namespace Baya.Domain.Entities.User;
|
||||
|
||||
public class UserRefreshToken:BaseEntity<Guid>
|
||||
{
|
||||
public UserRefreshToken()
|
||||
{
|
||||
CreatedAt=DateTime.Now;
|
||||
}
|
||||
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public bool IsValid { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Baya.Domain.Common;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Baya.Domain.Entities.User;
|
||||
|
||||
public class UserRole : IdentityUserRole<int>,IEntity
|
||||
{
|
||||
public User User { get; set; }
|
||||
public Role Role { get; set; }
|
||||
public DateTime CreatedUserRoleDate { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Baya.Domain.Common;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Baya.Domain.Entities.User;
|
||||
|
||||
public class UserToken:IdentityUserToken<int>,IEntity
|
||||
{
|
||||
public UserToken()
|
||||
{
|
||||
GeneratedTime=DateTime.Now;
|
||||
}
|
||||
|
||||
public User User { get; set; }
|
||||
public DateTime GeneratedTime { get; set; }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user