mirror of
https://github.com/QuotifyTeam/QuotifyBE.git
synced 2025-12-16 19:20:06 +01:00
feat: paginate categories
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization.Infrastructure;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Update.Internal;
|
||||
using QuotifyBE.Data;
|
||||
using QuotifyBE.DTOs;
|
||||
using QuotifyBE.Entities;
|
||||
using QuotifyBE.Mapping;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace QuotifyBE.Controllers;
|
||||
@@ -50,7 +47,7 @@ public class QuotesController : ControllerBase
|
||||
[EnableCors]
|
||||
[ProducesResponseType(typeof(List<QuoteShortDTO>), 200)]
|
||||
[ProducesResponseType(typeof(ErrorDTO), 404)]
|
||||
public async Task<IActionResult> GetQuotePage(int page_no, string? sort = "desc", [FromQuery] string? category_id = null)
|
||||
public async Task<IActionResult> GetQuotePage(int page_no = 1, string? sort = "desc", [FromQuery] string? category_id = null)
|
||||
{
|
||||
var totalQuotes = await _db.Quotes.CountAsync();
|
||||
const int PageSize = 10;
|
||||
@@ -197,7 +194,10 @@ public class QuotesController : ControllerBase
|
||||
if ( !request.ImageUrl.StartsWith("http://")
|
||||
&& !request.ImageUrl.StartsWith("https://")
|
||||
&& !request.ImageUrl.StartsWith("/"))
|
||||
return StatusCode(406, new ErrorDTO { Status = "error", Error_msg = "Image URLs should point to http/https url or a local resource" });
|
||||
return StatusCode(406, new ErrorDTO {
|
||||
Status = "error",
|
||||
Error_msg = "Image URLs should point to http/https url or a local resource"
|
||||
});
|
||||
|
||||
image = new Image { Url = request.ImageUrl };
|
||||
_db.Images.Add(image);
|
||||
@@ -414,7 +414,10 @@ public class QuotesController : ControllerBase
|
||||
if ( !updatedQuote.ImageUrl.StartsWith("http://")
|
||||
&& !updatedQuote.ImageUrl.StartsWith("https://")
|
||||
&& !updatedQuote.ImageUrl.StartsWith("/"))
|
||||
return StatusCode(406, new ErrorDTO { Status = "error", Error_msg = "Image URLs should point to http/https url or a local resource" });
|
||||
return StatusCode(406, new ErrorDTO {
|
||||
Status = "error",
|
||||
Error_msg = "Image URLs should point to http/https url or a local resource"
|
||||
});
|
||||
|
||||
image = new Image { Url = updatedQuote.ImageUrl };
|
||||
_db.Images.Add(image);
|
||||
|
||||
Reference in New Issue
Block a user