SkiServiceModels
Contents
CoreEF Models
Service Model
public class Service : IGenericModel { [Key] public int Id { get; set; } [StringLength(50)] public string Name { get; set; } [StringLength(1000)] public string Description { get; set; } public int Price { get; set; } public bool IsDeleted { get; set; } = false; }
public class Service : ServiceBase, IGenericEFModel { [Key] public int Id { get; set; } }
Priority Model
public class Priority : IGenericModel { [Key] public int Id { get; set; } [StringLength(20)] public string Name { get; set; } public int Days { get; set; } public bool IsDeleted { get; set; } = false; }
public class Priority : PriorityBase, IGenericEFModel { [Key] public int Id { get; set; } }
State Model
public class State : IGenericModel { [Key] public int Id { get; set; } [StringLength(20)] public string Name { get; set; } public bool IsDeleted { get; set; } = false; }
public class State : StateBase, IGenericEFModel { [Key] public int Id { get; set; } }
User Model
public class User : IGenericModel { [Key] public int Id { get; set; } [StringLength(50)] public string Username { get; set; } public byte[] PasswordHash { get; set; } public byte[] PasswordSalt { get; set; } public bool Locked { get; set; } = false; public RoleNames Role { get; set; } = RoleNames.User; public int LoginAttempts { get; set; } = 0; public bool IsDeleted { get; set; } = false; public string RefreshToken { get; set; } = null; }
public class User : UserBase, IGenericEFModel { [Key] public int Id { get; set; } }
Order Model
public class Order : OrderBase, IGenericEFModelpublic class Order : IGenericModel{ [Key] public int Id { get; set; } // Foreign keys public int ServiceId { get; set; } public int PriorityId { get; set; } public int StateId { get; set; } public int? UserId { get; set; } = null; // Navigation properties public virtual User? User { get; set; } public virtual Service Service { get; set; } public virtual Priority Priority { get; set; }public virtual Priority Priority { get; set; }public virtual State State { get; set; }[StringLength(50)]public string Name { get; set; }[StringLength(100)]public string Email { get; set; }[StringLength(20)]public string Phone { get; set; }[StringLength(1000)]public string? Note { get; set; } = null;public DateTime Created { get; set; } = DateTime.Now;public bool IsDeleted { get; set; } = false;}
BSON Models
Service Model
public class Service : ServiceBase, IGenericBSONModel { [BsonId] [BsonRepresentation(BsonType.ObjectId)] public string Id { get; set; } }
Priority Model
public class Priority : PriorityBase, IGenericBSONModel { [BsonId] [BsonRepresentation(BsonType.ObjectId)] public string Id { get; set; } }
State Model
public class State : StateBase, IGenericBSONModel { [BsonId] [BsonRepresentation(BsonType.ObjectId)] public string Id { get; set; } }
User Model
public class User : UserBase, IGenericBSONModel { [BsonId] [BsonRepresentation(BsonType.ObjectId)] public string Id { get; set; } }
Order Model
public class Order : OrderBase, IGenericBSONModel { [BsonId] [BsonRepresentation(BsonType.ObjectId)] public string Id { get; set; } public string PriorityId { get; set; } public string ServiceId { get; set; } public string StateId { get; set; } public string? UserId { get; set; } = null; [BsonIgnore] public virtual Priority Priority { get; set; } [BsonIgnore] public virtual Service Service { get; set; } [BsonIgnore] public virtual State State { get; set; } [BsonIgnore] public virtual User? User { get; set; } }
DTOs
TokenData
This DTO is used for any token data sent by the API.
public class TokenData : IDTO { public string Token { get; set; } public string? RefreshToken { get; set; } public string TokenType { get; set; } = "Bearer"; public DateTime Issued { get; set; } = DateTime.UtcNow; public DateTime Expires { get; set; } }
ErrorData
This DTO is used for any error data sent by the API.
public class ErrorData : IDTO { public string MessageCode { get; set; } public bool Breaking { get; set; } = false; }
DeleteResponse
public class DeleteResponse : IResponseDTO { public int Count { get; set; }public int Id { get; set; }}
LoginResponse
public class LoginResponse : UserResponse, IResponseDTO { public TokenData Auth { get; set; } }
OrderResponse
public class OrderResponse : IResponseDTO { public int Id { get; set; } public string Name { get; set; } public string Email { get; set; } public string Phone { get; set; } public string? Note { get; set; } public DateTime Created { get; set; } // Navigation properties public UserResponse User { get; set; } public ServiceResponse Service { get; set; } public PriorityResponse Priority { get; set; } public StateResponse State { get; set; } } public class OrderResponseAdmin : OrderResponse, IResponseDTO { public bool IsDeleted { get; set; } // Navigation properties new public UserResponseAdmin User { get; set; } new public ServiceResponseAdmin Service { get; set; } new public PriorityResponseAdmin Priority { get; set; } new public StateResponseAdmin State { get; set; } }
PriorityResponse
public class PriorityResponse : IResponseDTO { public int Id { get; set; } public string Name { get; set; } public int Days { get; set; } } public class PriorityResponseAdmin : PriorityResponse, IResponseDTO { public bool IsDeleted { get; set; } }
ServiceResponse
public class ServiceResponse : IResponseDTO { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } public int Price { get; set; } } public class ServiceResponseAdmin : ServiceResponse, IResponseDTO { public bool IsDeleted { get; set; } }
StateResponse
public class StateResponse : IResponseDTO { public int Id { get; set; } public string Name { get; set; } } public class StateResponseAdmin : StateResponse, IResponseDTO { public bool IsDeleted { get; set; } }
UserResponse
public class UserResponse : IResponseDTO { public int Id { get; set; } public string Username { get; set; } public bool Locked { get; set; } public RoleNames Role { get; set; } } public class UserResponseAdmin : UserResponse, IResponseDTO { public bool IsDeleted { get; set; } public int LoginAttempts { get; set; } = 0; }
LoginRequest
public class LoginRequest : ILoginRequest { [Required] public string Username { get; set; } [Required] public string Password { get; set; } public bool RememberMe { get; set; } = false; }
RefreshRequest
public class RefreshRequest : ILoginRequest { [Required] public string Token { get; set; } [Required] public string RefreshToken { get; set; } }
CreateOrderRequest
public class CreateOrderRequest : IRequestDTO { [Required] public int ServiceId { get; set; } [Required] public int PriorityId { get; set; } [Required] public int StateId { get; set; } public int? UserId { get; set; } [Required] [StringLength(50)] public string Name { get; set; } [Required] [StringLength(100)] [EmailAddress] public string Email { get; set; } [Required] [StringLength(20)] [RegularExpression(@"^(\+\d{1,3}[- ]?)?\d{10}$", ErrorMessage = "Invalid phone number")] public string Phone { get; set; } [StringLength(1000)] public string? Note { get; set; } = null; }
CreatePriorityRequest
public class CreatePriorityRequest : IRequestDTO { [Required] [StringLength(20)] public string Name { get; set; } [Required] [Range(1, 365)] public int Days { get; set; } }
CreateServiceRequest
public class CreateServiceRequest : IRequestDTO { [Required] [StringLength(50)] public string Name { get; set; } [Required] [StringLength(1000)] public string Description { get; set; } [Required] [Range(1, 1000)] public int Price { get; set; } }
CreateStateRequest
public class CreateStateRequest : IRequestDTO { [Required] [StringLength(20)] public string Name { get; set; } }
CreateUserRequest
public class CreateUserRequest : IRequestDTO { [Required] [StringLength(50)] public string Username { get; set; } [Required] [MinLength(8)] public string Password { get; set; } public bool? Locked { get; set; } public RoleNames? Role { get; set; } }
UpdateOrderRequest
public class UpdateOrderRequest : IRequestDTO { public int? ServiceId { get; set; } = null;public int? ServiceId { get; set; }public int? PriorityId { get; set; } = null;public int? PriorityId { get; set; }public int? StateId { get; set; } = null;public int? StateId { get; set; }public int? UserId { get; set; } = null;public int? UserId { get; set; }[StringLength(50)] public string? Name { get; set; } = null;public string? Name { get; set; }[StringLength(100)] [EmailAddress] public string? Email { get; set; } = null;public string? Email { get; set; }[StringLength(20)] [RegularExpression(@"^(\+\d{1,3}[- ]?)?\d{10}$", ErrorMessage = "Invalid phone number")] public string? Phone { get; set; } = null;public string? Phone { get; set; }[StringLength(1000)] public string? Note { get; set; } = null; }
UpdatePriorityRequest
public class UpdatePriorityRequest : IRequestDTO { [StringLength(20)] public string? Name { get; set; } = null;public string? Name { get; set; }[Range(1, 365)] public int? Days { get; set; } = null;public int? Days { get; set; }}
UpdateServiceRequest
public class UpdateServiceRequest : IRequestDTO { [StringLength(50)] public string? Name { get; set; } = null;public string? Name { get; set; }[StringLength(1000)] public string? Description { get; set; } = null;public string? Description { get; set; }[Range(1, 1000)] public int? Price { get; set; } = null;public int? Price { get; set; }}
UpdateStateRequest
public class UpdateStateRequest : IRequestDTO { [StringLength(20)] public string? Name { get; set; } = null;public string? Name { get; set; }}
UpdateUserRequest
public class UpdateUserRequest : IRequestDTO { [StringLength(50)] public string? Username { get; set; } = null;public string? Username { get; set; }[MinLength(8)] public string? Password { get; set; } = null;public string? Password { get; set; }public bool? Locked { get; set; } = null;public bool? Locked { get; set; }public RoleNames? Role { get; set; } = null;public RoleNames? Role { get; set; }}
Enums
RoleNames Enum
public enum RoleNames { User, SuperAdmin }
IGenericModel Interface
Base Interface for all models.
public interface IGenericModel { bool IsDeleted { get; set; } }
IGenericEFModel Interface
Base Interface for all models.
public interface IGenericEFModel : IGenericModel { public int Id { get; set; } }
IGenericBSONModel Interface
Base Interface for all models.
public interface IGenericBSONModel : IGenericModelpublic interface IGenericModel{ public string Id { get; set; }int Id { get; set; }bool IsDeleted { get; set; }}
DTO Interface
Base Interface for all DTOs.
public interface IDTO { }
Response DTO Interface
Base Interface for all Response DTOs.
public interface IResponseDTO : IDTO { }
Request DTO Interface
Base Interface for all Request DTOs.
public interface IRequestDTO : IDTO { }
ILoginRequest Interface
Interface for LoginRequest & RefreshRequest
public interface ILoginRequest : IRequestDTO { }