73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
using Core.Abstractions.Models;
|
|
using Core.Models;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using WeatherForecast.Models;
|
|
using WeatherForecast.Models.Responses;
|
|
|
|
namespace WeatherForecast.Controllers;
|
|
|
|
[AllowAnonymous]
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class ShopCatalogController : ControllerBase {
|
|
|
|
private readonly ILogger<ShopCatalogController> _logger;
|
|
|
|
public ShopCatalogController(ILogger<ShopCatalogController> logger) {
|
|
_logger = logger;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="category"></param>
|
|
/// <param name="searchText"></param>
|
|
/// <param name="currentPage"></param>
|
|
/// <param name="itemsPerPage"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public IActionResult Get([FromQuery] Guid? category, [FromQuery] string? searchText, [FromQuery] int currentPage = 1, [FromQuery] int itemsPerPage = 8) {
|
|
|
|
var shopModels = new List<ShopItemModel>();
|
|
for (int i = 0; i < 8; i++) {
|
|
var shopItemModel = new ShopItemModel {
|
|
Id = Guid.NewGuid(),
|
|
Sku = "SKU-0",
|
|
Slug = "shop-catalog-item",
|
|
Image = new ImageModel { Src = "https://dummyimage.com/450x300/dee2e6/6c757d.jpg", Alt = "..." },
|
|
Badge = "sale",
|
|
Title = "Shop item title",
|
|
|
|
ShortText = "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
|
Text = "",
|
|
Author = new AuthorModel {
|
|
// Id = Guid.NewGuid(),
|
|
Image = new ImageModel { Src = "https://dummyimage.com/40x40/ced4da/6c757d", Alt = "..." },
|
|
NickName = "Admin"
|
|
},
|
|
Created = DateTime.UtcNow,
|
|
|
|
Tags = new List<string> { "react", "redux", "webapi" },
|
|
|
|
Rating = 4.5,
|
|
Price = 20,
|
|
NewPrice = 10
|
|
};
|
|
|
|
shopModels.Add(shopItemModel);
|
|
}
|
|
|
|
var shopCatalogResponse = new GetShopCatalogResponseModel {
|
|
/*ShopItemsPagination = new PaginationModelBase<ShopItemModel> {
|
|
CurrentPage = currentPage,
|
|
TotalPages = 100,
|
|
Items = shopModels
|
|
}*/
|
|
};
|
|
|
|
|
|
return Ok(shopCatalogResponse);
|
|
}
|
|
}
|