58 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Microsoft.AspNetCore.Mvc;
 | |
| using Microsoft.AspNetCore.Authorization;
 | |
| using WeatherForecast.Models;
 | |
| using WeatherForecast.Models.Responses;
 | |
| 
 | |
| namespace WeatherForecast.Controllers {
 | |
| 
 | |
|   [AllowAnonymous]
 | |
|   [ApiController]
 | |
|   [Route("api/[controller]")]
 | |
|   public class BlogFeaturedController : ControllerBase {
 | |
| 
 | |
|     private readonly ILogger<BlogFeaturedController> _logger;
 | |
| 
 | |
|     public BlogFeaturedController(ILogger<BlogFeaturedController> logger) {
 | |
|       _logger = logger;
 | |
|     }
 | |
| 
 | |
|     /// <summary>
 | |
|     /// 
 | |
|     /// </summary>
 | |
|     /// <returns></returns>
 | |
|     [HttpGet]
 | |
|     public IActionResult Get() {
 | |
| #if MOCK_SERVER
 | |
|       var blogItems = new List<BlogItemModel>();
 | |
|       for (int i = 0; i < 3; i++) {
 | |
|         blogItems.Add(new BlogItemModel {
 | |
|           Id = Guid.NewGuid(),
 | |
|           Slug = "blog-post-title",
 | |
|           Image = new ImageModel { Src = "https://dummyimage.com/600x350/ced4da/6c757d", Alt = "..." },
 | |
|           Badge = "news",
 | |
|           Title = "C# 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<string> { "react", "redux", "webapi" },
 | |
| 
 | |
|           ReadTime = 10,
 | |
|           Likes = 200,
 | |
|         });
 | |
|       }
 | |
| 
 | |
|       var result = new GetBlogFeaturedResponseModel(blogItems);
 | |
| 
 | |
|       return Ok(result);
 | |
| #else
 | |
|       return Ok();
 | |
| #endif
 | |
|     }
 | |
|   }
 | |
| }
 |