using Microsoft.AspNetCore.Mvc; using Core.Models; using WeatherForecast.Models; using Microsoft.AspNetCore.Authorization; using Core.Abstractions.Models; using WeatherForecast.Models.Responses; namespace WeatherForecast.Controllers; [AllowAnonymous] [ApiController] [Route("api/[controller]")] public class BlogCatalogController : ControllerBase { private readonly ILogger _logger; public BlogCatalogController(ILogger logger) { _logger = logger; } /// /// /// /// /// /// /// /// [HttpGet] public IActionResult Get([FromQuery] Guid? category, [FromQuery] string? searchText, [FromQuery] int currentPage = 1, [FromQuery] int itemsPerPage = 4) { var blogModels = new List(); for (int i = 0; i < 100; i++) { var blogItemModel = new BlogItemModel { Id = Guid.NewGuid(), Slug = "blog-post-title", Image = new ImageModel { Src = "https://dummyimage.com/850x350/dee2e6/6c757d.jpg", Alt = "..." }, Badge = "news", Title = $"Blog post title {i}", ShortText = "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...", Text = "", Author = new AuthorModel { Image = new ImageModel { Src = "https://dummyimage.com/40x40/ced4da/6c757d", Alt = "..." }, NickName = "Admin" }, Created = DateTime.UtcNow, Tags = new List { "react", "redux", "webapi" }, ReadTime = 10, Likes = 200, }; blogModels.Add(blogItemModel); } var totalPages = blogModels.Count() / itemsPerPage; var blogCatalogResponse = new GetBlogCatalogResponseModel { /* FeaturedBlog = blogModels[0], BlogItemsPagination = new PaginationModelBase { CurrentPage = currentPage, TotalPages = totalPages, Items = blogModels.Skip((currentPage -1) * itemsPerPage).Take(itemsPerPage).ToList() }, Categories = new List { new CategoryModel { Id = Guid.NewGuid(), Text = "Web Design" }, new CategoryModel { Id = Guid.NewGuid(), Text = "Html" }, new CategoryModel { Id = Guid.NewGuid(), Text = "Freebies" }, new CategoryModel { Id = Guid.NewGuid(), Text = "Javascript" }, new CategoryModel { Id = Guid.NewGuid(), Text = "CSS" }, new CategoryModel { Id = Guid.NewGuid(), Text = "Tutorials" } }*/ }; return Ok(blogCatalogResponse); } }