36 lines
979 B
C#
36 lines
979 B
C#
using MongoDB.Bson;
|
|
using MongoDB.Bson.Serialization.Attributes;
|
|
|
|
namespace QuestionsApi.Models;
|
|
|
|
public static class CreditEconomy
|
|
{
|
|
public const int RollingEarningLimit = 20;
|
|
public static readonly TimeSpan EarningWindow = TimeSpan.FromHours(24);
|
|
}
|
|
|
|
public sealed class CreditEvent
|
|
{
|
|
public string OperationId { get; set; } = "";
|
|
public DateTime CreatedUtc { get; set; }
|
|
}
|
|
|
|
public sealed class UserCreditAccount
|
|
{
|
|
[BsonId]
|
|
[BsonRepresentation(BsonType.ObjectId)]
|
|
public string? Id { get; set; }
|
|
public string UserId { get; set; } = "";
|
|
public int Credits { get; set; }
|
|
public List<CreditEvent> RecentEarnings { get; set; } = [];
|
|
public DateTime UpdatedUtc { get; set; } = DateTime.UtcNow;
|
|
}
|
|
|
|
public sealed class CreditStatusResponse
|
|
{
|
|
public int Credits { get; set; }
|
|
public int EarnedInRollingWindow { get; set; }
|
|
public int RemainingEarningCapacity { get; set; }
|
|
public int RollingWindowHours { get; set; } = 24;
|
|
}
|