✨ Support multiple models in thought
This commit is contained in:
@@ -13,10 +13,10 @@ public class BillingController(AppDatabase db, ThoughtService thoughtService, IL
|
||||
[HttpGet("status")]
|
||||
public async Task<IActionResult> GetBillingStatus()
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||
return Unauthorized();
|
||||
var accountId = Guid.Parse(currentUser.Id);
|
||||
|
||||
|
||||
var isMarked = await db.UnpaidAccounts.AnyAsync(u => u.AccountId == accountId);
|
||||
return Ok(isMarked ? new { status = "unpaid" } : new { status = "ok" });
|
||||
}
|
||||
@@ -24,26 +24,19 @@ public class BillingController(AppDatabase db, ThoughtService thoughtService, IL
|
||||
[HttpPost("retry")]
|
||||
public async Task<IActionResult> RetryBilling()
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||
return Unauthorized();
|
||||
var accountId = Guid.Parse(currentUser.Id);
|
||||
|
||||
|
||||
var (success, cost) = await thoughtService.RetryBillingForAccountAsync(accountId, logger);
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (cost > 0)
|
||||
{
|
||||
return Ok(new { message = $"Billing retry successful. Billed {cost} points." });
|
||||
}
|
||||
else
|
||||
{
|
||||
return Ok(new { message = "No outstanding payment found." });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(new { message = "Billing retry failed. Please check your balance and try again." });
|
||||
return Ok(cost > 0
|
||||
? new { message = $"Billing retry successful. Billed {cost} points." }
|
||||
: new { message = "No outstanding payment found." });
|
||||
}
|
||||
|
||||
return BadRequest(new { message = "Billing retry failed. Please check your balance and try again." });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user