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
{
///
/// Configuration Information
///
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 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 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 bool IsQRCode { get; set; }
public bool IsSearchText { get; set; } // True if we want to have search box (text type), false otherwise
public bool IsSearchNumber { get; set; } // True if we want to have search box (number type), false otherwise
public ConfigurationDTO ToDTO(List 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 sections, List 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()
};
}
}
}