118 lines
4.0 KiB
C#
118 lines
4.0 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Defines the link between an application instance and a configuration,
|
|
/// allowing apps to use one or multiple configurations.
|
|
/// </summary>
|
|
public class ApplicationInstance
|
|
{
|
|
[Key]
|
|
public string Id { get; set; }
|
|
|
|
[Required]
|
|
public string InstanceId { get; set; }
|
|
|
|
[Required]
|
|
public AppType AppType { get; set; }
|
|
|
|
public List<AppConfigurationLink> Configurations { get; set; }
|
|
|
|
public string MainImageId { get; set; }
|
|
|
|
public string MainImageUrl { get; set; }
|
|
|
|
public string LoaderImageId { get; set; }
|
|
|
|
public string LoaderImageUrl { get; set; }
|
|
|
|
public bool IsDate { get; set; }
|
|
|
|
public bool IsHour { get; set; }
|
|
|
|
public string PrimaryColor { get; set; }
|
|
|
|
public string SecondaryColor { get; set; }
|
|
|
|
public int? RoundedValue { get; set; }
|
|
|
|
public int? ScreenPercentageSectionsMainPage { get; set; }
|
|
|
|
public bool IsSectionImageBackground { get; set; } // => Chose layout of main page
|
|
|
|
public LayoutMainPageType LayoutMainPage { get; set; } = LayoutMainPageType.MasonryGrid;
|
|
|
|
public List<string> Languages { get; set; } // All app must support languages, if not, client's problem
|
|
public string? SectionEventId { get; set; }
|
|
[ForeignKey("SectionEventId")]
|
|
public SectionEvent? SectionEvent { get; set; } // => To Display in large a event with countdown (in mobile app).
|
|
|
|
|
|
public ApplicationInstanceDTO ToDTO()
|
|
{
|
|
return new ApplicationInstanceDTO()
|
|
{
|
|
Id = Id,
|
|
InstanceId = InstanceId,
|
|
AppType = AppType,
|
|
Configurations = Configurations,
|
|
MainImageId = MainImageId,
|
|
MainImageUrl = MainImageUrl,
|
|
LoaderImageId = LoaderImageId,
|
|
LoaderImageUrl = LoaderImageUrl,
|
|
IsDate = IsDate,
|
|
IsHour = IsHour,
|
|
PrimaryColor = PrimaryColor,
|
|
SecondaryColor = SecondaryColor,
|
|
RoundedValue = RoundedValue,
|
|
ScreenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage,
|
|
IsSectionImageBackground = IsSectionImageBackground,
|
|
Languages = Languages
|
|
};
|
|
}
|
|
|
|
public ApplicationInstance FromDTO(ApplicationInstanceDTO applicationInstanceDTO)
|
|
{
|
|
return new ApplicationInstance()
|
|
{
|
|
Id = applicationInstanceDTO.Id,
|
|
InstanceId = applicationInstanceDTO.InstanceId,
|
|
AppType = applicationInstanceDTO.AppType,
|
|
MainImageId = applicationInstanceDTO.MainImageId,
|
|
MainImageUrl = applicationInstanceDTO.MainImageUrl,
|
|
LoaderImageId = applicationInstanceDTO.LoaderImageId,
|
|
LoaderImageUrl = applicationInstanceDTO.LoaderImageUrl,
|
|
IsDate = applicationInstanceDTO.IsDate,
|
|
IsHour = applicationInstanceDTO.IsHour,
|
|
PrimaryColor = applicationInstanceDTO.PrimaryColor,
|
|
SecondaryColor = applicationInstanceDTO.SecondaryColor,
|
|
RoundedValue = applicationInstanceDTO.RoundedValue,
|
|
ScreenPercentageSectionsMainPage = applicationInstanceDTO.ScreenPercentageSectionsMainPage,
|
|
IsSectionImageBackground = applicationInstanceDTO.IsSectionImageBackground,
|
|
Languages = applicationInstanceDTO.Languages,
|
|
Configurations = applicationInstanceDTO.Configurations,
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
public enum AppType
|
|
{
|
|
Mobile,
|
|
Tablet,
|
|
VR
|
|
}
|
|
|
|
public enum LayoutMainPageType
|
|
{
|
|
SimpleGrid,
|
|
MasonryGrid
|
|
}
|
|
}
|