Initial commit
This commit is contained in:
commit
63ee71a19b
123 files changed
+11268
No files matched your search
@@ -0,0 +1,4 @@
|
||||
namespace OnlyPrompt.Backend.ApiModels.Auth
|
||||
{
|
||||
public record ApiUser(Guid Id, string UserName, string Email, string[] Roles);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using OnlyPrompt.Backend.ApiModels.Validators;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace OnlyPrompt.Backend.ApiModels.Auth
|
||||
{
|
||||
public record ApiLoginRequest(string UserNameOrEmail, string Password);
|
||||
public record ApiRegisterRequest([MaxLength(100)] string DisplayName, [MaxLength(100)][NoWhitespace] string? UserName, string Email, string Password);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace OnlyPrompt.Backend.ApiModels.Category
|
||||
{
|
||||
public record ApiCategory(Guid Id, string Name, string Slug, string? Description);
|
||||
public record ApiMinimalCategory(string Name, string Slug);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace OnlyPrompt.Backend.ApiModels.Category
|
||||
{
|
||||
public record ApiCreateCategoryRequest(string Name, string? Slug, string? Description);
|
||||
public record ApiUpdateCategoryRequest(string? Name, string? Slug, string? Description);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace OnlyPrompt.Backend.ApiModels.Prompt
|
||||
{
|
||||
public enum FeedSortType
|
||||
{
|
||||
Date,
|
||||
Rating
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace OnlyPrompt.Backend.ApiModels.Prompt
|
||||
{
|
||||
public record ApiPrompt(Guid Id, string Title, string Description, string Content, DateTime TimeStamp, Guid CreatorId, string CreatorName, int? TierLevel, string? TierName, double? AverageRating);
|
||||
public record ApiMinimalPrompt(Guid Id, string Title, DateTime TimeStamp, Guid CreatorId, string CreatorName, int? TierLevel, string? TierName, double? AverageRating, bool CanAccess);
|
||||
public record ApiReview(Guid CreatorId, string CreatorName, string? Comment, int Rating);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
using OnlyPrompt.Backend.Utils;
|
||||
|
||||
namespace OnlyPrompt.Backend.ApiModels.Prompt
|
||||
{
|
||||
public record ApiCreatePromptRequest(string Title, string Description, string Content, Identifier Category, int? SubscriptionTier, string Slug);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace OnlyPrompt.Backend.ApiModels.Subscription
|
||||
{
|
||||
public record ApiSubscriptionTier(Guid Id, string Name, int Level, decimal MonthlyPrice, string? Description);
|
||||
public record ApiSubscription(Guid SubscribedToId, string SubscribedToName, ApiSubscriptionTier? CurrentTier);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace OnlyPrompt.Backend.ApiModels.Subscription
|
||||
{
|
||||
public record ApiCreateSubscriptionTierRequest(string Name, decimal MonthlyPrice, int Level, string? Description);
|
||||
public record ApiUpdateSubscriptionTierRequest(string? Name, decimal? MonthlyPrice, int? Level, string? Description);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace OnlyPrompt.Backend.ApiModels.UserProfile
|
||||
{
|
||||
public record ApiUserProfile(string DisplayName, string Slug, string? Bio, string AvatarUrl, string? Specialities, double AverageRating, int Subscribers);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using OnlyPrompt.Backend.ApiModels.Validators;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace OnlyPrompt.Backend.ApiModels.UserProfile
|
||||
{
|
||||
public record ApiUpdateProfileRequest([MaxLength(100)] string? DisplayName, [MaxLength(100)][NoWhitespace] string? Slug, string? Bio, string? AvatarUrl, string? Specialities, bool IsPublic);
|
||||
public record ApiCreateReviewRequest(string? Comment, [Range(1, 5)] int Rating);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace OnlyPrompt.Backend.ApiModels.Validators
|
||||
{
|
||||
public class NoWhitespaceAttribute : ValidationAttribute
|
||||
{
|
||||
public override bool IsValid(object? value)
|
||||
{
|
||||
if (value is string strValue)
|
||||
{
|
||||
if (strValue.Any(c => char.IsWhiteSpace(c)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true; // If it's not a string, we consider it valid. Use [NoWhitespace] only on string properties.
|
||||
}
|
||||
|
||||
protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
|
||||
{
|
||||
if(value is string strValue)
|
||||
{
|
||||
if(strValue.Any(c => char.IsWhiteSpace(c)))
|
||||
return new ValidationResult($"{validationContext.DisplayName} should not contain any whitespace characters.");
|
||||
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
|
||||
return ValidationResult.Success; // If it's not a string, we consider it valid. Use [NoWhitespace] only on string properties.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user