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()
};
}
}
}