154 lines
3.7 KiB
C#
154 lines
3.7 KiB
C#
using Core.Abstractions.DomainObjects;
|
|
using Core.Abstractions.Models;
|
|
using Core.DomainObjects;
|
|
using Core.Enumerations;
|
|
using WeatherForecast.Models.Responses;
|
|
using WeatherForecast.Models.Responses.L10n;
|
|
|
|
namespace WeatherForecast.Models.Abstractions {
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
public abstract class PostItemResponseModelBase<T> : ResponseModelBase {
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public Guid Id { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public Guid SiteId { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public List<PostItemL10nModel>? L10n { get; set; }
|
|
|
|
#region Localized costrutor
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? Slug { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? Description { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? Title { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? ShortText { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? Text { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? PlainText { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? ContentType { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public List<string>? Badges { get; set; }
|
|
#endregion
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public List<ImageResponseModel>? Images { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public AuthorModel? Author { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public DateTime Created { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public List<string>? Tags { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public List<CategoryItemResponseModel>? Categories { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public bool? FamilyFriendly { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="postItem"></param>
|
|
public PostItemResponseModelBase(PostItemBase<T> postItem) {
|
|
Id = postItem.Id;
|
|
SiteId = postItem.SiteId;
|
|
//Author = new AuthorModel(postItem.Author);
|
|
Created = postItem.Created;
|
|
Tags = postItem.Tags;
|
|
FamilyFriendly = postItem.FamilyFriendly;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="postItem"></param>
|
|
/// <param name="categories"></param>
|
|
public PostItemResponseModelBase(PostItemBase<T> postItem, List<Category> categories) : this(postItem) {
|
|
L10n = postItem.L10n.Select(x => new PostItemL10nModel(x)).ToList();
|
|
Categories = categories.Select(x => new CategoryItemResponseModel(x)).ToList();
|
|
Images = postItem.Images?.Select(x => new ImageResponseModel(x)).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="postItem"></param>
|
|
/// <param name="categories"></param>
|
|
/// <param name="locale"></param>
|
|
public PostItemResponseModelBase(PostItemBase<T> postItem, List<Category> categories, Locales locale) : this(postItem) {
|
|
|
|
var postItemL10n = postItem.L10n.Single(x => x.Locale == locale);
|
|
|
|
if (postItemL10n != null) {
|
|
Slug = postItemL10n.Slug;
|
|
Badges = postItemL10n.Badges;
|
|
Title = postItemL10n.Title;
|
|
ShortText = postItemL10n.ShortText;
|
|
Text = postItemL10n.Text;
|
|
PlainText = postItemL10n.PlainText;
|
|
Badges = postItemL10n.Badges;
|
|
}
|
|
|
|
Categories = categories.Select(x => new CategoryItemResponseModel(x, locale)).ToList();
|
|
Images = postItem.Images?.Select(x => new ImageResponseModel(x, locale)).ToList();
|
|
}
|
|
}
|
|
}
|