forked from slavaxom9k/PIBD-23_Fomichev_V.S._MagicCarpet
33 lines
913 B
C#
33 lines
913 B
C#
using MagicCarpetContracts.Infrastructure.PostConfigurations;
|
|
using MagicCarpetContracts.Mapper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MagicCarpetContracts.ViewModels;
|
|
|
|
public class PostViewModel
|
|
{
|
|
[AlternativeName("PostId")]
|
|
public required string Id { get; set; }
|
|
|
|
public required string PostName { get; set; }
|
|
|
|
public required string PostType { get; set; }
|
|
|
|
[AlternativeName("ConfigurationModel")]
|
|
[PostProcessing(MappingCallMethodName = "ParseConfiguration")]
|
|
public required string Configuration { get; set; }
|
|
|
|
private string ParseConfiguration(PostConfiguration? model)
|
|
{
|
|
if (model == null)
|
|
return string.Empty;
|
|
|
|
return JsonSerializer.Serialize(model, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
|
}
|
|
}
|