(feat): blog controllers
This commit is contained in:
parent
4d0133ada9
commit
a1071da8bf
@ -1,20 +1,19 @@
|
|||||||
using Core.DomainObjects.Documents;
|
using Microsoft.Extensions.Logging;
|
||||||
using DataProviders.Abstractions;
|
|
||||||
using DomainResults.Common;
|
using DomainResults.Common;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using MongoDB.Bson.Serialization;
|
using MongoDB.Bson.Serialization;
|
||||||
using MongoDB.Driver;
|
using MongoDB.Driver;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using DataProviders.Abstractions;
|
||||||
using System.Linq;
|
using Core.DomainObjects.Documents;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataProviders {
|
namespace DataProviders {
|
||||||
|
|
||||||
public interface IBlogCatalogDataProvider {
|
public interface IBlogCatalogDataProvider {
|
||||||
(Guid?, IDomainResult) Insert(BlogItem blogItem);
|
(Guid?, IDomainResult) Insert(BlogItem blogItem);
|
||||||
|
(BlogItem?, IDomainResult) Get(Guid siteId, Guid blogId);
|
||||||
(BlogItem?, IDomainResult) Get(Guid siteId, string slug);
|
(BlogItem?, IDomainResult) Get(Guid siteId, string slug);
|
||||||
|
(BlogItem?, IDomainResult) Get(Guid siteId, List<string> slugs);
|
||||||
(List<BlogItem>?, IDomainResult) GetAll(Guid siteId, int skip, int take);
|
(List<BlogItem>?, IDomainResult) GetAll(Guid siteId, int skip, int take);
|
||||||
(Guid?, IDomainResult) Update(BlogItem blogItem);
|
(Guid?, IDomainResult) Update(BlogItem blogItem);
|
||||||
IDomainResult Delete(Guid id);
|
IDomainResult Delete(Guid id);
|
||||||
@ -35,8 +34,20 @@ namespace DataProviders {
|
|||||||
public (Guid?, IDomainResult) Insert(BlogItem blogItem) =>
|
public (Guid?, IDomainResult) Insert(BlogItem blogItem) =>
|
||||||
Insert(blogItem, _collectionName);
|
Insert(blogItem, _collectionName);
|
||||||
|
|
||||||
public (BlogItem?, IDomainResult) Get(Guid siteId, string slug) {
|
public (BlogItem?, IDomainResult) Get(Guid siteId, Guid blogId) {
|
||||||
var (list, result) = GetWithPredicate(x => x.SiteId == siteId && x.L10n.Where(y => y.Slug == slug).Count() > 0, _collectionName);
|
var (list, result) = GetWithPredicate(x => x.SiteId == siteId && x.Id == blogId, _collectionName);
|
||||||
|
|
||||||
|
if (!result.IsSuccess || list == null)
|
||||||
|
return (null, result);
|
||||||
|
|
||||||
|
return (list.First(), result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public (BlogItem?, IDomainResult) Get(Guid siteId, string slug) =>
|
||||||
|
Get(siteId, new List<string> { slug });
|
||||||
|
|
||||||
|
public (BlogItem?, IDomainResult) Get(Guid siteId, List<string> slugs) {
|
||||||
|
var (list, result) = GetWithPredicate(x => x.SiteId == siteId && x.L10n.Any(y => slugs.Contains(y.Slug)), _collectionName);
|
||||||
|
|
||||||
if (!result.IsSuccess || list == null)
|
if (!result.IsSuccess || list == null)
|
||||||
return (null, result);
|
return (null, result);
|
||||||
|
|||||||
@ -13,9 +13,8 @@ namespace DataProviders {
|
|||||||
public interface ICategoryDataProvider {
|
public interface ICategoryDataProvider {
|
||||||
(Guid?, IDomainResult) Insert(Category obj);
|
(Guid?, IDomainResult) Insert(Category obj);
|
||||||
(Category?, IDomainResult) Get(Guid siteId, Guid categoryId);
|
(Category?, IDomainResult) Get(Guid siteId, Guid categoryId);
|
||||||
|
(Category?, IDomainResult) Get(Guid siteId, string slug);
|
||||||
(Category?, IDomainResult) Get(Guid siteId, List<string> slugs);
|
(Category?, IDomainResult) Get(Guid siteId, List<string> slugs);
|
||||||
|
|
||||||
(List<Category>?, IDomainResult) GetAll(Guid siteId);
|
(List<Category>?, IDomainResult) GetAll(Guid siteId);
|
||||||
(Guid?, IDomainResult) Update(Category obj);
|
(Guid?, IDomainResult) Update(Category obj);
|
||||||
IDomainResult Delete(Guid id);
|
IDomainResult Delete(Guid id);
|
||||||
@ -44,6 +43,9 @@ namespace DataProviders {
|
|||||||
return (list.First(), result);
|
return (list.First(), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public (Category?, IDomainResult) Get(Guid siteId, string slug) =>
|
||||||
|
Get(siteId, new List<string> { slug });
|
||||||
|
|
||||||
public (Category?, IDomainResult) Get(Guid siteId, List<string> slugs) {
|
public (Category?, IDomainResult) Get(Guid siteId, List<string> slugs) {
|
||||||
var (list, result) = GetWithPredicate(x => x.SiteId == siteId && x.L10n.Any(y => slugs.Contains(y.Slug)), _collectionName);
|
var (list, result) = GetWithPredicate(x => x.SiteId == siteId && x.L10n.Any(y => slugs.Contains(y.Slug)), _collectionName);
|
||||||
|
|
||||||
@ -53,15 +55,6 @@ namespace DataProviders {
|
|||||||
return (list.First(), result);
|
return (list.First(), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public (Category?, IDomainResult) Get(Guid siteId, string slug) {
|
|
||||||
var (list, result) = GetWithPredicate(x => x.SiteId == siteId && x.L10n.Where(x => x.Slug == slug).Count() > 0 , _collectionName);
|
|
||||||
|
|
||||||
if (!result.IsSuccess || list == null)
|
|
||||||
return (null, result);
|
|
||||||
|
|
||||||
return (list.First(), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public (List<Category>?, IDomainResult) GetAll(Guid siteId) =>
|
public (List<Category>?, IDomainResult) GetAll(Guid siteId) =>
|
||||||
GetWithPredicate(x => x.SiteId == siteId, _collectionName);
|
GetWithPredicate(x => x.SiteId == siteId, _collectionName);
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ namespace DataProviders {
|
|||||||
(ShopCartItem?, IDomainResult) Get(Guid siteId, Guid userId, string sku);
|
(ShopCartItem?, IDomainResult) Get(Guid siteId, Guid userId, string sku);
|
||||||
(Guid?, IDomainResult) Update(ShopCartItem shopCart);
|
(Guid?, IDomainResult) Update(ShopCartItem shopCart);
|
||||||
IDomainResult Delete(Guid id);
|
IDomainResult Delete(Guid id);
|
||||||
|
IDomainResult DeleteAll(Guid siteId, Guid userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ShopCartDataProvider : DataProviderBase<ShopCartItem>, IShopCartDataProvider {
|
public class ShopCartDataProvider : DataProviderBase<ShopCartItem>, IShopCartDataProvider {
|
||||||
@ -47,5 +48,8 @@ namespace DataProviders {
|
|||||||
|
|
||||||
public IDomainResult Delete(Guid id) =>
|
public IDomainResult Delete(Guid id) =>
|
||||||
DeleteWithPredicate(x => x.Id == id, _collectionName);
|
DeleteWithPredicate(x => x.Id == id, _collectionName);
|
||||||
|
|
||||||
|
public IDomainResult DeleteAll(Guid siteId, Guid userId) =>
|
||||||
|
DeleteWithPredicate(x => x.SiteId == siteId && x.UserId == userId, _collectionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,8 @@ namespace DataProviders {
|
|||||||
public interface IShopCatalogDataProvider {
|
public interface IShopCatalogDataProvider {
|
||||||
(Guid?, IDomainResult) Insert(ShopItem obj);
|
(Guid?, IDomainResult) Insert(ShopItem obj);
|
||||||
(ShopItem?, IDomainResult) Get(Guid siteId, string sku);
|
(ShopItem?, IDomainResult) Get(Guid siteId, string sku);
|
||||||
|
//(ShopItem?, IDomainResult) Get(Guid siteId, string slug);
|
||||||
|
(ShopItem?, IDomainResult) Get(Guid siteId, List<string> slugs);
|
||||||
(List<ShopItem>?, IDomainResult) GetAll(Guid siteId, int skip, int take);
|
(List<ShopItem>?, IDomainResult) GetAll(Guid siteId, int skip, int take);
|
||||||
(Guid?, IDomainResult) Update(ShopItem shopCart);
|
(Guid?, IDomainResult) Update(ShopItem shopCart);
|
||||||
IDomainResult Delete(Guid id);
|
IDomainResult Delete(Guid id);
|
||||||
@ -41,6 +43,18 @@ namespace DataProviders {
|
|||||||
return (list.First(), result);
|
return (list.First(), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//public (ShopItem?, IDomainResult) Get(Guid siteId, string slug) =>
|
||||||
|
// Get(siteId, new List<string> { slug });
|
||||||
|
|
||||||
|
public (ShopItem?, IDomainResult) Get(Guid siteId, List<string> slugs) {
|
||||||
|
var (list, result) = GetWithPredicate(x => x.SiteId == siteId && x.L10n.Any(y => slugs.Contains(y.Slug)), _collectionName);
|
||||||
|
|
||||||
|
if (!result.IsSuccess || list == null)
|
||||||
|
return (null, result);
|
||||||
|
|
||||||
|
return (list.First(), result);
|
||||||
|
}
|
||||||
|
|
||||||
public (List<ShopItem>?, IDomainResult) GetAll(Guid siteId, int skip, int take) =>
|
public (List<ShopItem>?, IDomainResult) GetAll(Guid siteId, int skip, int take) =>
|
||||||
GetWithPredicate(x => x.SiteId == siteId, skip, take, _collectionName);
|
GetWithPredicate(x => x.SiteId == siteId, skip, take, _collectionName);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Core.Abstractions;
|
||||||
|
using Core.Enumerations;
|
||||||
|
using WeatherForecast.Services;
|
||||||
|
using DomainResults.Mvc;
|
||||||
|
using WeatherForecast.Models.Requests;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers {
|
||||||
|
|
||||||
@ -9,18 +14,72 @@ namespace WeatherForecast.Controllers {
|
|||||||
public class BlogItemController : ControllerBase {
|
public class BlogItemController : ControllerBase {
|
||||||
|
|
||||||
private readonly ILogger<BlogItemController> _logger;
|
private readonly ILogger<BlogItemController> _logger;
|
||||||
|
private readonly IBlogItemService _blogItemService;
|
||||||
|
|
||||||
public BlogItemController(ILogger<BlogItemController> logger) {
|
public BlogItemController(
|
||||||
|
ILogger<BlogItemController> logger,
|
||||||
|
IBlogItemService blogItemService
|
||||||
|
) {
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_blogItemService = blogItemService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="requestData"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpPost("{siteId}")]
|
||||||
public IActionResult Get() {
|
public IActionResult Post([FromRoute] Guid siteId, [FromBody] PostBlogItemRequestModel requestData) {
|
||||||
return Ok();
|
var result = _blogItemService.Post(siteId, requestData);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns full object
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{siteId}/{blogId}")]
|
||||||
|
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid blogId) {
|
||||||
|
var result = _blogItemService.Get(siteId, blogId);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns localized object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{siteId}")]
|
||||||
|
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
|
||||||
|
var result = _blogItemService.Get(siteId, slug);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="blogId"></param>
|
||||||
|
/// <param name="requestData"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut("{siteId}/{blogId}")]
|
||||||
|
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid blogId, [FromBody] PutBlogItemRequestModel requestData) {
|
||||||
|
var result = _blogItemService.Update(siteId, blogId, requestData);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="blogId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("{siteId}/{blogId}")]
|
||||||
|
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid blogId) {
|
||||||
|
var result = _blogItemService.Delete(siteId, blogId);
|
||||||
|
return result.ToActionResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
using DomainResults.Mvc;
|
using DomainResults.Mvc;
|
||||||
using WeatherForecast.Models.Requests;
|
using WeatherForecast.Models.Requests;
|
||||||
|
using Core.Enumerations;
|
||||||
|
using Core.Abstractions;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers {
|
||||||
|
|
||||||
@ -12,7 +14,7 @@ namespace WeatherForecast.Controllers {
|
|||||||
public class CategoryItemController : ControllerBase {
|
public class CategoryItemController : ControllerBase {
|
||||||
|
|
||||||
private readonly ILogger<CategoryItemController> _logger;
|
private readonly ILogger<CategoryItemController> _logger;
|
||||||
private readonly ICategoryItemService _categoryItemService;
|
private readonly ICategoryItemService _categoryItemService;
|
||||||
|
|
||||||
public CategoryItemController(
|
public CategoryItemController(
|
||||||
ILogger<CategoryItemController> logger,
|
ILogger<CategoryItemController> logger,
|
||||||
@ -21,29 +23,64 @@ namespace WeatherForecast.Controllers {
|
|||||||
_categoryItemService = categoryItemService;
|
_categoryItemService = categoryItemService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="requestData"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("{siteId}")]
|
[HttpPost("{siteId}")]
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromBody] PostCategoryItemRequestModel requestData) {
|
public IActionResult Post([FromRoute] Guid siteId, [FromBody] PostCategoryItemRequestModel requestData) {
|
||||||
var result = _categoryItemService.Post(siteId, requestData);
|
var result = _categoryItemService.Post(siteId, requestData);
|
||||||
return result.ToActionResult();
|
return result.ToActionResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Returns full object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="categoryId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{siteId}/{categoryId}")]
|
[HttpGet("{siteId}/{categoryId}")]
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid categoryId) {
|
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid categoryId) {
|
||||||
var result = _categoryItemService.Get(siteId, categoryId);
|
var result = _categoryItemService.Get(siteId, categoryId);
|
||||||
return result.ToActionResult();
|
return result.ToActionResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns localized object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{siteId}")]
|
||||||
|
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
|
||||||
|
var result = _categoryItemService.Get(siteId, slug);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="categoryId"></param>
|
||||||
|
/// <param name="requestData"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut("{siteId}/{categoryId}")]
|
||||||
|
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid categoryId, [FromBody] PutCategoryItemRequestModel requestData) {
|
||||||
|
var result = _categoryItemService.Update(siteId, categoryId, requestData);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="categoryId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("{siteId}/{categoryId}")]
|
||||||
|
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid categoryId) {
|
||||||
|
var result = _categoryItemService.Delete(siteId, categoryId);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,13 @@ namespace WeatherForecast.Controllers {
|
|||||||
var result = _shopCartItemsService.Get(siteId, userId, Enumeration.FromDisplayName<Locales>(locale) ?? Locales.Us);
|
var result = _shopCartItemsService.Get(siteId, userId, Enumeration.FromDisplayName<Locales>(locale) ?? Locales.Us);
|
||||||
return result.ToActionResult();
|
return result.ToActionResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpDelete("{siteId}/{userId}")]
|
||||||
|
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId) {
|
||||||
|
var result = _shopCartItemsService.Delete(siteId, userId);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,14 +38,25 @@ namespace WeatherForecast.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Returns full object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="sku"></param>
|
/// <param name="sku"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{siteId}/{sku}")]
|
[HttpGet("{siteId}/{sku}")]
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] string sku, [FromQuery] string locale) {
|
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] string sku) {
|
||||||
var result = _shopItemService.Get(siteId, sku, Enumeration.FromDisplayName<Locales>(locale) ?? Locales.Us);
|
var result = _shopItemService.Get(siteId, sku);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns localized object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{siteId}")]
|
||||||
|
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
|
||||||
|
var result = _shopItemService.Get(siteId, slug);
|
||||||
return result.ToActionResult();
|
return result.ToActionResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,13 +4,19 @@ using Core.DomainObjects.L10n;
|
|||||||
using Core.Enumerations;
|
using Core.Enumerations;
|
||||||
|
|
||||||
namespace WeatherForecast.Models.L10n {
|
namespace WeatherForecast.Models.L10n {
|
||||||
public class CategoryL10nModel : RequestModelBase<CategoryL10n> {
|
public class CategoryL10nModel : ModelBase {
|
||||||
|
|
||||||
public string Locale { get; set; }
|
public string Locale { get; set; }
|
||||||
public string Slug { get; set; }
|
public string Slug { get; set; }
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
|
|
||||||
public override CategoryL10n ToDomainObject() => new CategoryL10n {
|
public CategoryL10nModel(CategoryL10n categoryL10n) {
|
||||||
|
Locale = categoryL10n.Locale.Name;
|
||||||
|
Slug = categoryL10n.Slug;
|
||||||
|
Text = categoryL10n.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CategoryL10n ToDomainObject() => new CategoryL10n {
|
||||||
Locale = Enumeration.FromDisplayName<Locales>(Locale),
|
Locale = Enumeration.FromDisplayName<Locales>(Locale),
|
||||||
Slug = Slug,
|
Slug = Slug,
|
||||||
Text = Text
|
Text = Text
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using Core.DomainObjects.L10n;
|
|||||||
using Core.Enumerations;
|
using Core.Enumerations;
|
||||||
|
|
||||||
namespace WeatherForecast.Models.L10n {
|
namespace WeatherForecast.Models.L10n {
|
||||||
public class PostItemL10nModel : RequestModelBase<PostItemL10n> {
|
public class PostItemL10nModel : ModelBase {
|
||||||
public string Locale { get; set; }
|
public string Locale { get; set; }
|
||||||
public string Slug { get; set; }
|
public string Slug { get; set; }
|
||||||
|
|
||||||
@ -17,7 +17,18 @@ namespace WeatherForecast.Models.L10n {
|
|||||||
public string ContentType { get; set; }
|
public string ContentType { get; set; }
|
||||||
public List<string> Badges { get; set; }
|
public List<string> Badges { get; set; }
|
||||||
|
|
||||||
public override PostItemL10n ToDomainObject() => new PostItemL10n {
|
public PostItemL10nModel(PostItemL10n postItemL10n) {
|
||||||
|
Locale = postItemL10n.Locale.Name;
|
||||||
|
Slug = postItemL10n.Slug;
|
||||||
|
Description = postItemL10n.Description;
|
||||||
|
Title = postItemL10n.Title;
|
||||||
|
ShortText = postItemL10n.ShortText;
|
||||||
|
Text = postItemL10n.Text;
|
||||||
|
ContentType = postItemL10n.ContentType.Name;
|
||||||
|
Badges = postItemL10n.Badges;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PostItemL10n ToDomainObject() => new PostItemL10n {
|
||||||
Locale = Enumeration.FromDisplayName<Locales>(Locale),
|
Locale = Enumeration.FromDisplayName<Locales>(Locale),
|
||||||
Slug = Slug,
|
Slug = Slug,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
@ -32,6 +43,4 @@ namespace WeatherForecast.Models.L10n {
|
|||||||
Badges = Badges
|
Badges = Badges
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
using Core.Abstractions.Models;
|
||||||
|
using Core.DomainObjects.Documents;
|
||||||
|
|
||||||
|
namespace WeatherForecast.Models.Requests {
|
||||||
|
public class PostBlogItemRequestModel : RequestModelBase<BlogItem> {
|
||||||
|
public override BlogItem ToDomainObject() {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,14 @@
|
|||||||
using Core.Abstractions.Models;
|
using Core.Abstractions.Models;
|
||||||
using Core.DomainObjects;
|
using Core.DomainObjects;
|
||||||
|
using Core.DomainObjects.L10n;
|
||||||
using WeatherForecast.Models.L10n;
|
using WeatherForecast.Models.L10n;
|
||||||
|
|
||||||
namespace WeatherForecast.Models.Requests {
|
namespace WeatherForecast.Models.Requests {
|
||||||
public class PostCategoryItemRequestModel : RequestModelBase<Category> {
|
public class PostCategoryItemRequestModel : RequestModelBase<Category> {
|
||||||
|
|
||||||
public List<CategoryL10nModel> L10n { get; set; }
|
public List<CategoryL10nModel> L10n { get; set; }
|
||||||
public override Category ToDomainObject() {
|
public override Category ToDomainObject() => new Category {
|
||||||
throw new NotImplementedException();
|
L10n = L10n.Select(x => x.ToDomainObject()).ToList()
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
using Core.Abstractions.Models;
|
||||||
|
using Core.DomainObjects.Documents;
|
||||||
|
|
||||||
|
namespace WeatherForecast.Models.Requests {
|
||||||
|
public class PutBlogItemRequestModel : RequestModelBase<BlogItem> {
|
||||||
|
public override BlogItem ToDomainObject() {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,10 +1,12 @@
|
|||||||
using Core.Abstractions.Models;
|
using Core.Abstractions.Models;
|
||||||
using Core.DomainObjects;
|
using Core.DomainObjects;
|
||||||
|
using WeatherForecast.Models.L10n;
|
||||||
|
|
||||||
namespace WeatherForecast.Models.Requests {
|
namespace WeatherForecast.Models.Requests {
|
||||||
public class PutCategoryItemRequestModel : RequestModelBase<Category> {
|
public class PutCategoryItemRequestModel : RequestModelBase<Category> {
|
||||||
public override Category ToDomainObject() {
|
public List<CategoryL10nModel> L10n { get; set; }
|
||||||
throw new NotImplementedException();
|
public override Category ToDomainObject() => new Category {
|
||||||
}
|
L10n = L10n.Select(x => x.ToDomainObject()).ToList()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,19 @@
|
|||||||
using Core.Abstractions.Models;
|
using Core.Abstractions.Models;
|
||||||
using Core.DomainObjects;
|
using Core.DomainObjects;
|
||||||
using Core.Enumerations;
|
using Core.Enumerations;
|
||||||
|
using WeatherForecast.Models.L10n;
|
||||||
|
|
||||||
namespace WeatherForecast.Models.Responses {
|
namespace WeatherForecast.Models.Responses {
|
||||||
public class GetCategoryItemResponseModel : ResponseModelBase {
|
public class GetCategoryItemResponseModel : ResponseModelBase {
|
||||||
|
|
||||||
public string Slug { get; set; }
|
public string? Slug { get; set; }
|
||||||
public string Text { get; set; }
|
public string? Text { get; set; }
|
||||||
|
|
||||||
|
public List<CategoryL10nModel>? L10n { get; set; }
|
||||||
|
|
||||||
|
public GetCategoryItemResponseModel(Category category) {
|
||||||
|
L10n = category.L10n.Select(x => new CategoryL10nModel(x)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public GetCategoryItemResponseModel(Category category, Locales locale) {
|
public GetCategoryItemResponseModel(Category category, Locales locale) {
|
||||||
var l10n = category.L10n.SingleOrDefault(x => x.Locale == locale);
|
var l10n = category.L10n.SingleOrDefault(x => x.Locale == locale);
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace WeatherForecast {
|
namespace WeatherForecast {
|
||||||
public class Program {
|
public class Program {
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
@ -6,6 +8,10 @@ namespace WeatherForecast {
|
|||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
Host.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
|
.UseSerilog((hostContext, services, configuration) => {
|
||||||
|
configuration.ReadFrom.Configuration(hostContext.Configuration)
|
||||||
|
.Enrich.FromLogContext();
|
||||||
|
})
|
||||||
.ConfigureWebHostDefaults(webBuilder => {
|
.ConfigureWebHostDefaults(webBuilder => {
|
||||||
webBuilder.UseStartup<Startup>();
|
webBuilder.UseStartup<Startup>();
|
||||||
});
|
});
|
||||||
|
|||||||
81
webapi/WeatherForecast/Services/BlogItemService.cs
Normal file
81
webapi/WeatherForecast/Services/BlogItemService.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
using Core.DomainObjects;
|
||||||
|
using Core.Enumerations;
|
||||||
|
using DataProviders;
|
||||||
|
using DomainResults.Common;
|
||||||
|
using WeatherForecast.Models.Requests;
|
||||||
|
using WeatherForecast.Models.Responses;
|
||||||
|
|
||||||
|
namespace WeatherForecast.Services {
|
||||||
|
|
||||||
|
public interface IBlogItemService {
|
||||||
|
(Guid?, IDomainResult) Post(Guid siteId, PostBlogItemRequestModel requestModel);
|
||||||
|
(GetBlogItemResponseModel, IDomainResult) Get(Guid siteId, Guid blogId);
|
||||||
|
(GetBlogItemResponseModel, IDomainResult) Get(Guid siteId, string slug);
|
||||||
|
(Guid?, IDomainResult) Update(Guid siteId, Guid blogId, PutBlogItemRequestModel requestData);
|
||||||
|
IDomainResult Delete(Guid siteId, Guid blogId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BlogItemService : IBlogItemService {
|
||||||
|
private readonly ILogger<BlogItemService> _logger;
|
||||||
|
private readonly IBlogCatalogDataProvider _blogCatalogDataProvider;
|
||||||
|
private readonly ICategoryDataProvider _categoryDataProvider;
|
||||||
|
|
||||||
|
public BlogItemService(
|
||||||
|
ILogger<BlogItemService> logger,
|
||||||
|
IBlogCatalogDataProvider blogCatalogDataProvider
|
||||||
|
) {
|
||||||
|
_logger = logger;
|
||||||
|
_blogCatalogDataProvider = blogCatalogDataProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public (Guid?, IDomainResult) Post(Guid siteId, PostBlogItemRequestModel requestModel) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public (GetBlogItemResponseModel?, IDomainResult) Get(Guid siteId, Guid blogId) {
|
||||||
|
var (item, result) = _blogCatalogDataProvider.Get(siteId, blogId);
|
||||||
|
|
||||||
|
if (!result.IsSuccess || item == null)
|
||||||
|
return (null, result);
|
||||||
|
|
||||||
|
var categories = new List<Category>();
|
||||||
|
foreach (var catId in item.Categories) {
|
||||||
|
var (category, getCategoryResult) = _categoryDataProvider.Get(catId, siteId);
|
||||||
|
if (!getCategoryResult.IsSuccess || category == null)
|
||||||
|
return (null, getCategoryResult);
|
||||||
|
|
||||||
|
categories.Add(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
return IDomainResult.Success(new GetBlogItemResponseModel(item, categories, Locales.Us));
|
||||||
|
}
|
||||||
|
|
||||||
|
public (GetBlogItemResponseModel?, IDomainResult) Get(Guid siteId, string slug) {
|
||||||
|
var (item, result) = _blogCatalogDataProvider.Get(siteId, slug);
|
||||||
|
|
||||||
|
if (!result.IsSuccess || item == null)
|
||||||
|
return (null, result);
|
||||||
|
|
||||||
|
var locale = item.L10n.SingleOrDefault(x => x.Slug == slug)?.Locale ?? Locales.Us;
|
||||||
|
|
||||||
|
var categories = new List<Category>();
|
||||||
|
foreach (var catId in item.Categories) {
|
||||||
|
var (category, getCategoryResult) = _categoryDataProvider.Get(catId, siteId);
|
||||||
|
if (!getCategoryResult.IsSuccess || category == null)
|
||||||
|
return (null, getCategoryResult);
|
||||||
|
|
||||||
|
categories.Add(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
return IDomainResult.Success(new GetBlogItemResponseModel(item, categories, locale));
|
||||||
|
}
|
||||||
|
|
||||||
|
public (Guid?, IDomainResult) Update(Guid siteId, Guid blogId, PutBlogItemRequestModel requestData) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDomainResult Delete(Guid siteId, Guid blogId) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -50,7 +50,6 @@ namespace WeatherForecast.Services {
|
|||||||
: IDomainResult.NotFound<GetBlogItemsResponseModel?>();
|
: IDomainResult.NotFound<GetBlogItemsResponseModel?>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDomainResult Delete(Guid siteId) =>
|
public IDomainResult Delete(Guid siteId) => _blogCatalogDataProvider.DeleteAll(siteId);
|
||||||
_blogCatalogDataProvider.DeleteAll(siteId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ namespace WeatherForecast.Services {
|
|||||||
public interface ICategoryItemService {
|
public interface ICategoryItemService {
|
||||||
(Guid?, IDomainResult) Post(Guid siteId, PostCategoryItemRequestModel requestModel);
|
(Guid?, IDomainResult) Post(Guid siteId, PostCategoryItemRequestModel requestModel);
|
||||||
(GetCategoryItemResponseModel?, IDomainResult) Get(Guid siteId, Guid categoryId);
|
(GetCategoryItemResponseModel?, IDomainResult) Get(Guid siteId, Guid categoryId);
|
||||||
|
(GetCategoryItemResponseModel?, IDomainResult) Get(Guid siteId, string slug);
|
||||||
(Guid?, IDomainResult) Update(Guid siteId, Guid categoryId, PutCategoryItemRequestModel requestData);
|
(Guid?, IDomainResult) Update(Guid siteId, Guid categoryId, PutCategoryItemRequestModel requestData);
|
||||||
IDomainResult Delete(Guid siteId, Guid categoryId);
|
IDomainResult Delete(Guid siteId, Guid categoryId);
|
||||||
}
|
}
|
||||||
@ -47,7 +48,17 @@ namespace WeatherForecast.Services {
|
|||||||
if (!result.IsSuccess || item == null)
|
if (!result.IsSuccess || item == null)
|
||||||
return (null, result);
|
return (null, result);
|
||||||
|
|
||||||
return IDomainResult.Success(new GetCategoryItemResponseModel(item, Locales.Us));
|
return IDomainResult.Success(new GetCategoryItemResponseModel(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
public (GetCategoryItemResponseModel?, IDomainResult) Get(Guid siteId, string slug) {
|
||||||
|
var (item, result) = _categoryDataProvider.Get(siteId, slug);
|
||||||
|
if (!result.IsSuccess || item == null)
|
||||||
|
return (null, result);
|
||||||
|
|
||||||
|
var locale = item.L10n.SingleOrDefault(x => x.Slug == slug)?.Locale ?? Locales.Us;
|
||||||
|
|
||||||
|
return IDomainResult.Success(new GetCategoryItemResponseModel(item, locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
public (Guid?, IDomainResult) Update(Guid siteId, Guid categoryId, PutCategoryItemRequestModel requestData) {
|
public (Guid?, IDomainResult) Update(Guid siteId, Guid categoryId, PutCategoryItemRequestModel requestData) {
|
||||||
|
|||||||
@ -31,10 +31,6 @@ namespace WeatherForecast.Services {
|
|||||||
return IDomainResult.Success(items.Select(x => new GetCategoryItemResponseModel(x, locale)).ToList());
|
return IDomainResult.Success(items.Select(x => new GetCategoryItemResponseModel(x, locale)).ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDomainResult Delete(Guid siteId) {
|
public IDomainResult Delete(Guid siteId) => _categoryDataProvider.DeleteAll(siteId);
|
||||||
var resutl = _categoryDataProvider.DeleteAll(siteId);
|
|
||||||
return resutl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,13 @@ using WeatherForecast.Models.Responses;
|
|||||||
|
|
||||||
using DataProviders;
|
using DataProviders;
|
||||||
|
|
||||||
using Core.Abstractions;
|
|
||||||
using Core.DomainObjects.Documents;
|
|
||||||
using Core.Enumerations;
|
using Core.Enumerations;
|
||||||
|
|
||||||
namespace WeatherForecast.Services {
|
namespace WeatherForecast.Services {
|
||||||
|
|
||||||
public interface IShopCartItemsService {
|
public interface IShopCartItemsService {
|
||||||
(List<GetShopCartItemResponseModel>?, IDomainResult) Get(Guid siteId, Guid userId, Locales locale);
|
(List<GetShopCartItemResponseModel>?, IDomainResult) Get(Guid siteId, Guid userId, Locales locale);
|
||||||
|
IDomainResult Delete(Guid siteId, Guid userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ShopCartItemsService : IShopCartItemsService {
|
public class ShopCartItemsService : IShopCartItemsService {
|
||||||
@ -49,5 +48,7 @@ namespace WeatherForecast.Services {
|
|||||||
? IDomainResult.Success(items)
|
? IDomainResult.Success(items)
|
||||||
: IDomainResult.NotFound<List<GetShopCartItemResponseModel>?>();
|
: IDomainResult.NotFound<List<GetShopCartItemResponseModel>?>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IDomainResult Delete(Guid siteId, Guid userId) => _shopCartDataProvider.DeleteAll(siteId, userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ namespace WeatherForecast.Services {
|
|||||||
|
|
||||||
public interface IShopItemService {
|
public interface IShopItemService {
|
||||||
(Guid?, IDomainResult) Post(Guid siteId, string sku, PostShopItemRequestModel requestModel);
|
(Guid?, IDomainResult) Post(Guid siteId, string sku, PostShopItemRequestModel requestModel);
|
||||||
(GetShopItemResponseModel, IDomainResult) Get(Guid siteId, string sku, Locales locale);
|
(GetShopItemResponseModel, IDomainResult) Get(Guid siteId, string sku);
|
||||||
(Guid?, IDomainResult) Update(Guid siteId, string sku, PutShopItemRequestModel requestData);
|
(Guid?, IDomainResult) Update(Guid siteId, string sku, PutShopItemRequestModel requestData);
|
||||||
IDomainResult Delete(Guid siteId, string sku);
|
IDomainResult Delete(Guid siteId, string sku);
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ namespace WeatherForecast.Services {
|
|||||||
return IDomainResult.Success(id);
|
return IDomainResult.Success(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public (GetShopItemResponseModel?, IDomainResult) Get(Guid siteId, string sku, Locales locale) {
|
public (GetShopItemResponseModel?, IDomainResult) Get(Guid siteId, string sku) {
|
||||||
var (item, result) = _shopCatalogDataProvider.Get(siteId, sku);
|
var (item, result) = _shopCatalogDataProvider.Get(siteId, sku);
|
||||||
|
|
||||||
if (!result.IsSuccess || item == null)
|
if (!result.IsSuccess || item == null)
|
||||||
@ -84,7 +84,7 @@ namespace WeatherForecast.Services {
|
|||||||
categories.Add(category);
|
categories.Add(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
return IDomainResult.Success(new GetShopItemResponseModel(item, categories, locale));
|
return IDomainResult.Success(new GetShopItemResponseModel(item, categories, Locales.Us));
|
||||||
}
|
}
|
||||||
|
|
||||||
public (Guid?, IDomainResult) Update(Guid siteId, string sku, PutShopItemRequestModel requestData) {
|
public (Guid?, IDomainResult) Update(Guid siteId, string sku, PutShopItemRequestModel requestData) {
|
||||||
|
|||||||
@ -53,7 +53,6 @@ namespace WeatherForecast.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IDomainResult Delete(Guid siteId)
|
public IDomainResult Delete(Guid siteId) => _shopCatalogDataProvider.DeleteAll(siteId);
|
||||||
=> _shopCatalogDataProvider.DeleteAll(siteId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ using Microsoft.IdentityModel.Tokens;
|
|||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
using DataProviders.Extensions;
|
using DataProviders.Extensions;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace WeatherForecast {
|
namespace WeatherForecast {
|
||||||
public class Startup {
|
public class Startup {
|
||||||
@ -33,10 +34,9 @@ namespace WeatherForecast {
|
|||||||
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
|
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
services.AddControllers();
|
|
||||||
|
|
||||||
|
services.AddControllers().AddJsonOptions(options =>
|
||||||
|
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull);
|
||||||
|
|
||||||
// configure jwt authentication
|
// configure jwt authentication
|
||||||
services.AddAuthentication(options => {
|
services.AddAuthentication(options => {
|
||||||
@ -62,7 +62,7 @@ namespace WeatherForecast {
|
|||||||
services.AddScoped<IShopItemsService, ShopItemsService>();
|
services.AddScoped<IShopItemsService, ShopItemsService>();
|
||||||
services.AddScoped<IShopCartItemService, ShopCartItemService>();
|
services.AddScoped<IShopCartItemService, ShopCartItemService>();
|
||||||
services.AddScoped<IShopCartItemsService, ShopCartItemsService>();
|
services.AddScoped<IShopCartItemsService, ShopCartItemsService>();
|
||||||
//services.AddScoped<IBlogItemService, BlogItemService>();
|
services.AddScoped<IBlogItemService, BlogItemService>();
|
||||||
services.AddScoped<IBlogItemsService, BlogItemsService>();
|
services.AddScoped<IBlogItemsService, BlogItemsService>();
|
||||||
services.AddScoped<ICategoryItemService, CategoryItemService>();
|
services.AddScoped<ICategoryItemService, CategoryItemService>();
|
||||||
services.AddScoped<ICategoryItemsService, CategoryItemsService>();
|
services.AddScoped<ICategoryItemsService, CategoryItemsService>();
|
||||||
|
|||||||
@ -16,6 +16,11 @@
|
|||||||
<PackageReference Include="DomainResult" Version="3.0.0" />
|
<PackageReference Include="DomainResult" Version="3.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.5" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
|
||||||
|
<PackageReference Include="Serilog.Expressions" Version="3.4.0" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,17 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"Serilog": {
|
||||||
"LogLevel": {
|
"Using": [ "Serilog.Settings.Configuration", "Serilog.Expressions", "Serilog.Sinks.Console" ],
|
||||||
"Default": "Information",
|
"MinimumLevel": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ],
|
||||||
}
|
"WriteTo": [
|
||||||
|
{
|
||||||
|
"Name": "Console",
|
||||||
|
"Args": {
|
||||||
|
"restrictedToMinimumLevel": "Information",
|
||||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{Method}) {Message}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"Configuration": {
|
"Configuration": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user