92 lines
2.9 KiB
C#

using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
namespace ManagerService.Data
{
/// <summary>
/// Configuration Information
/// </summary>
public class Configuration
{
[Key]
[Required]
public string Id { get; set; }
[Required]
public string InstanceId { get; set; }
[Required]
public string Label { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Title { get; set; }
public string ImageId { get; set; }
public string ImageSource { get; set; }
public string PrimaryColor { get; set; } // Config can have their specific colors
public string SecondaryColor { get; set; } // Config can have their specific colors
public List<string> Languages { get; set; } // Config can support not all the languages (help to translate step by step)
public DateTime DateCreation { get; set; }
public bool IsOffline { get; set; }
public string LoaderImageId { get; set; } // Config can have their specific loader if needed
public string LoaderImageUrl { get; set; } // Config can have their specific loader if needed
public ConfigurationDTO ToDTO(List<string> sectionIds)
{
return new ConfigurationDTO()
{
Id = Id,
InstanceId = InstanceId,
Label = Label,
Title = Title,
ImageId = ImageId,
ImageSource = ImageSource,
LoaderImageId = LoaderImageId,
LoaderImageUrl = LoaderImageUrl,
DateCreation = DateCreation,
PrimaryColor = PrimaryColor,
Languages = Languages,
SecondaryColor = SecondaryColor,
IsOffline = IsOffline,
sectionIds = sectionIds
};
}
public ExportConfigurationDTO ToExportDTO(List<SectionDTO> sections, List<ResourceDTO> resources) {
return new ExportConfigurationDTO()
{
Id = Id,
InstanceId = InstanceId,
Label = Label,
Title = Title,
ImageId = ImageId,
ImageSource = ImageSource,
LoaderImageId = LoaderImageId,
LoaderImageUrl = LoaderImageUrl,
DateCreation = DateCreation,
PrimaryColor = PrimaryColor,
Languages = Languages,
SecondaryColor = SecondaryColor,
IsOffline = IsOffline,
sections = sections,
resources = resources,
sectionIds = sections.Select(s => s.id).ToList()
};
}
}
}