57 lines
1.4 KiB
C#

using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Content
/// </summary>
public class Content
{
[Key]
[Required]
public int Id { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Title { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Description { get; set; }
public string ResourceId { get; set; }
public Resource Resource { get; set; }
public int Order { get; set; } // Order to show
public ContentDTO ToDTO()
{
return new ContentDTO()
{
title = Title.ToList(),
description = Description,
order = Order,
resourceId = ResourceId,
resource = Resource.ToDTO()
};
}
public Content FromDTO(ContentDTO contentDTO)
{
return new Content()
{
Title = contentDTO.title,
Description = contentDTO.description,
Order = contentDTO.order,
ResourceId = contentDTO.resourceId
};
}
}
}