using Microsoft.AspNetCore.Mvc; using Core.Models; using WeatherForecast.Models; using Microsoft.AspNetCore.Authorization; using Core.Abstractions.Models; namespace WeatherForecast.Controllers; #region Input models public class GetBlogCatalogResponse : ResponseModel { public BlogItemModel FeaturedBlog { get; set; } public List Categories { get; set; } public PaginationModel BlogItemsPagination { get; set; } } #endregion [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 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", 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 { "react", "redux", "webapi" }, ReadTime = 10, Likes = 200, }; var blogModels = new List(); for (int i = 0; i < itemsPerPage; i++) { blogModels.Add(blogItemModel); } var blogCatalogResponse = new GetBlogCatalogResponse { FeaturedBlog = blogItemModel, BlogItemsPagination = new PaginationModel { CurrentPage = currentPage, TotalPages = 100, Items = blogModels }, 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); } }