-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
news article list of non-logged in is added + routes modified a bit
- Loading branch information
1 parent
ced1bf5
commit 9f58c41
Showing
14 changed files
with
112 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
AdvancedAPI.Data/ViewModels/NewsArticle/NewsArticleResponseModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// <copyright file="NewsArticleResponseModel.cs" company="PlaceholderCompany"> | ||
// Copyright (c) PlaceholderCompany. All rights reserved. | ||
// </copyright> | ||
|
||
namespace AdvancedAPI.Data.ViewModels.NewsArticle; | ||
|
||
/// <summary> | ||
/// Response model for news article. | ||
/// </summary> | ||
public class NewsArticleResponseModel | ||
{ | ||
/// <summary> | ||
/// identifier. | ||
/// </summary> | ||
public int Id { get; set; } | ||
|
||
/// <summary> | ||
/// Header text. | ||
/// </summary> | ||
public string HeaderText { get; set; } | ||
Check warning on line 20 in AdvancedAPI.Data/ViewModels/NewsArticle/NewsArticleResponseModel.cs GitHub Actions / build (Debug)
|
||
|
||
/// <summary> | ||
/// Content in HTML format. | ||
/// </summary> | ||
public string ContentHtml { get; set; } | ||
Check warning on line 25 in AdvancedAPI.Data/ViewModels/NewsArticle/NewsArticleResponseModel.cs GitHub Actions / build (Debug)
|
||
|
||
/// <summary> | ||
/// Release date of the article. | ||
/// </summary> | ||
public DateTime ReleaseDate { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using AdvancedAPI.BaseControllers; | ||
using AdvancedAPI.Data.ViewModels.NewsArticle; | ||
using Business.Services.Interfaces; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace AdvancedAPI.Controllers; | ||
|
||
/// <summary> | ||
/// News article endpoint without authorization. | ||
/// </summary> | ||
public class NewsArticleController : BaseController | ||
{ | ||
private readonly INewsArticleService _newsArticleService; | ||
|
||
/// <summary> | ||
/// Constructor. | ||
/// </summary> | ||
public NewsArticleController(INewsArticleService newsArticleService) | ||
{ | ||
_newsArticleService = newsArticleService; | ||
} | ||
|
||
/// <summary> | ||
/// Get list of news articles. | ||
/// </summary> | ||
[HttpGet] | ||
public async Task<IActionResult> GetList() | ||
{ | ||
List<NewsArticleResponseModel> newsArticles = await _newsArticleService.GetList(); | ||
return Ok(newsArticles); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.OpenApi.Models; | ||
using Swashbuckle.AspNetCore.SwaggerGen; | ||
|
||
namespace AdvancedAPI.Filters; | ||
|
||
/// <summary> | ||
/// Lower case filteer will convert the url paths to lowercase. | ||
/// </summary> | ||
public class LowercaseDocumentFilter : IDocumentFilter | ||
{ | ||
/// <summary> | ||
/// Applies the lowercase convertion. | ||
/// </summary> | ||
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) | ||
{ | ||
Dictionary<string, OpenApiPathItem> paths = swaggerDoc.Paths.ToDictionary( | ||
path => path.Key.ToLowerInvariant(), | ||
path => path.Value); | ||
|
||
swaggerDoc.Paths.Clear(); | ||
|
||
foreach (KeyValuePair<string, OpenApiPathItem> path in paths) | ||
{ | ||
swaggerDoc.Paths.Add(path.Key, path.Value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters