using ManagerService.Data.SubSection;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ManagerService.Data
{
///
/// Represents the association between an application instance (e.g., mobile or tablet app)
/// and a specific configuration. This link defines which configurations are used by which
/// application instances, optionally with an order or active status.
/// Useful for managing configuration assignment and display logic per app type.
///
public class AppConfigurationLink
{
[Key]
public string Id { get; set; }
[Required]
public string ConfigurationId { get; set; }
[Required]
public string ApplicationInstanceId { get; set; }
public int? Order { get; set; } // Specific Mobile
public bool IsActive { get; set; } = true; // Specific Mobile
public int? WeightMasonryGrid { get; set; } // Specific Mobile
public bool IsDate { get; set; } // Specific Kiosk
public bool IsHour { get; set; } // Specific Kiosk
public int? RoundedValue { get; set; } // Specific Kiosk
public int? ScreenPercentageSectionsMainPage { get; set; } // Specific Kiosk
public bool IsSectionImageBackground { get; set; } // => Chose layout of main page // Specific Kiosk
public LayoutMainPageType LayoutMainPage { get; set; } = LayoutMainPageType.MasonryGrid; // Specific Kiosk and mobile
public string LoaderImageId { get; set; } // Specific Kiosk
public string LoaderImageUrl { get; set; } // Specific Kiosk
public string PrimaryColor { get; set; } // Specific Kiosk
public string SecondaryColor { get; set; } // Specific Kiosk
[ForeignKey(nameof(ConfigurationId))]
public Configuration Configuration { get; set; }
[ForeignKey(nameof(ApplicationInstanceId))]
public ApplicationInstance ApplicationInstance { get; set; }
public string? DeviceId { get; set; } // Specific kiosk
[ForeignKey("DeviceId")]
public Device? Device { get; set; } // Specific kiosk
public AppConfigurationLinkDTO ToDTO()
{
return new AppConfigurationLinkDTO()
{
id = Id,
configurationId = ConfigurationId,
configuration = Configuration?.ToDTO(new List()),
applicationInstanceId = ApplicationInstanceId,
order = Order,
isActive = IsActive,
weightMasonryGrid = WeightMasonryGrid,
primaryColor = PrimaryColor,
secondaryColor = SecondaryColor,
loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl,
isDate = IsDate,
isHour = IsHour,
roundedValue = RoundedValue,
screenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage,
isSectionImageBackground = IsSectionImageBackground,
deviceId = DeviceId,
device = Device?.ToDTO()
};
}
public AppConfigurationLink FromDTO(AppConfigurationLinkDTO appConfigurationLinkDTO)
{
ConfigurationId = appConfigurationLinkDTO.configurationId;
ApplicationInstanceId = appConfigurationLinkDTO.applicationInstanceId;
Order = appConfigurationLinkDTO.order;
IsActive = appConfigurationLinkDTO.isActive;
WeightMasonryGrid = appConfigurationLinkDTO?.weightMasonryGrid;
PrimaryColor = appConfigurationLinkDTO.primaryColor;
SecondaryColor = appConfigurationLinkDTO.secondaryColor;
LoaderImageId = appConfigurationLinkDTO.loaderImageId;
LoaderImageUrl = appConfigurationLinkDTO.loaderImageUrl;
IsDate = appConfigurationLinkDTO.isDate;
IsHour = appConfigurationLinkDTO.isHour;
RoundedValue = appConfigurationLinkDTO.roundedValue;
ScreenPercentageSectionsMainPage = appConfigurationLinkDTO.screenPercentageSectionsMainPage;
IsSectionImageBackground = appConfigurationLinkDTO.isSectionImageBackground;
DeviceId = appConfigurationLinkDTO.deviceId;
return this;
}
}
}