61 lines
1.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Text.Json.Serialization;
namespace CORP_MAUI.Models;
/// <summary>
/// Модель комментария
/// </summary>
public class Comment
{
public int Id { get; set; }
[JsonPropertyName("content")]
public string Content { get; set; } = string.Empty;
[JsonPropertyName("body")]
public string? Body { get; set; }
[JsonPropertyName("text")]
public string? Text { get; set; }
[JsonIgnore]
public string DisplayContent
{
get
{
if (!string.IsNullOrWhiteSpace(Content)) return Content;
if (!string.IsNullOrWhiteSpace(Body)) return Body;
return Text ?? string.Empty;
}
}
public User? Author { get; set; }
[JsonPropertyName("post")]
public int Post { get; set; }
[JsonPropertyName("created_at")]
public DateTime CreatedAt { get; set; }
[JsonPropertyName("date")]
public DateTime? Date { get; set; }
[JsonIgnore]
public DateTime DisplayDate
{
get
{
// Если CreatedAt валидный (больше 2000 года, чтоб отсечь дефолт), берем его
DateTime d = CreatedAt.Year > 2000 ? CreatedAt : (Date ?? DateTime.Now);
return d.ToLocalTime();
}
}
[JsonPropertyName("updated_at")]
public DateTime UpdatedAt { get; set; }
[JsonPropertyName("likes_count")]
public int LikesCount { get; set; }
}