forked from slavaxom9k/PIBD-23_Fomichev_V.S._MagicCarpet
подготовка ко 2 миграции
This commit is contained in:
@@ -6,6 +6,7 @@ using MagicCarpetContracts.BuisnessLogicContracts;
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace MagicCarpetWebApi.Adapters;
|
||||
|
||||
@@ -17,6 +18,11 @@ public class PostAdapter : IPostAdapter
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
private readonly JsonSerializerOptions JsonSerializerOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
public PostAdapter(IPostBusinessLogicContract postBusinessLogicContract, ILogger<PostAdapter> logger)
|
||||
{
|
||||
_postBusinessLogicContract = postBusinessLogicContract;
|
||||
@@ -24,7 +30,8 @@ public class PostAdapter : IPostAdapter
|
||||
var config = new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<PostBindingModel, PostDataModel>();
|
||||
cfg.CreateMap<PostDataModel, PostViewModel>();
|
||||
cfg.CreateMap<PostDataModel, PostViewModel>()
|
||||
.ForMember(x => x.Configuration, x => x.MapFrom(src => JsonSerializer.Serialize(src.ConfigurationModel, JsonSerializerOptions)));
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user