using ManagerService.Data.SubSection;
using ManagerService.DTOs;
using MongoDB.Bson.Serialization.Attributes;
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]
/*[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]*/
public string Id { get; set; }
/*[BsonElement("Label")]
[BsonRequired]*/
[Required]
public string Label { get; set; }
/*[BsonElement("Title")]
[BsonRequired]*/
[Required]
[Column(TypeName = "jsonb")]
public List Title { get; set; }
/*[BsonElement("ImageId")]*/
public string ImageId { get; set; }
/*[BsonElement("ImageSource")]*/
public string ImageSource { get; set; }
/*[BsonElement("PrimaryColor")]*/
public string PrimaryColor { get; set; }
/*[BsonElement("SecondaryColor")]*/
public string SecondaryColor { get; set; }
/*[BsonElement("Languages")]*/
public List Languages { get; set; } // fr, en, de, nl => Sélection dans une liste déjà établie dans l'application !
/*[BsonElement("DateCreation")]*/
public DateTime DateCreation { get; set; }
/*[BsonElement("IsMobile")]*/
public bool IsMobile { get; set; }
/*[BsonElement("IsTablet")]*/
public bool IsTablet { get; set; }
/*[BsonElement("IsOffline")]*/
public bool IsOffline { get; set; }
/*[BsonElement("InstanceId")]
[BsonRequired]*/
[Required]
public string InstanceId { get; set; }
/*[BsonElement("LoaderImageId")]*/
public string LoaderImageId { get; set; }
/*[BsonElement("LoaderImageUrl")]*/
public string LoaderImageUrl { get; set; }
/*[BsonElement("WeatherCity")]*/
public string WeatherCity { get; set; }
/*[BsonElement("WeatherUpdatedDate")]*/
public DateTimeOffset? WeatherUpdatedDate { get; set; }
/*[BsonElement("WeatherResult")]*/
public string WeatherResult { get; set; }
/*[BsonElement("IsDate")]*/
public bool IsDate { get; set; }
/*[BsonElement("IsHour")]*/
public bool IsHour { get; set; }
/*[BsonElement("IsSectionImageBackground")]*/
public bool IsSectionImageBackground { get; set; }
/*[BsonElement("RoundedValue")]*/
public int? RoundedValue { get; set; }
/*[BsonElement("ScreenPercentageSectionsMainPage")]*/
public int? ScreenPercentageSectionsMainPage { get; set; }
public ConfigurationDTO ToDTO(List sectionIds)
{
return new ConfigurationDTO()
{
id = Id,
label = Label,
title = Title.Select(c => c.ToDTO()).ToList(),
imageId = ImageId,
imageSource = ImageSource,
loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl,
weatherCity = WeatherCity,
weatherUpdatedDate = WeatherUpdatedDate,
weatherResult = WeatherResult,
dateCreation = DateCreation,
primaryColor = PrimaryColor,
languages = Languages,
secondaryColor = SecondaryColor,
isMobile = IsMobile,
isTablet = IsTablet,
isOffline = IsOffline,
instanceId = InstanceId,
isDate = IsDate,
isHour = IsHour,
isSectionImageBackground = IsSectionImageBackground,
roundedValue = RoundedValue,
screenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage,
sectionIds = sectionIds
};
}
public ExportConfigurationDTO ToExportDTO(List sections, List resources) {
return new ExportConfigurationDTO()
{
id = Id,
label = Label,
title= Title.Select(c => c.ToDTO()).ToList(),
imageId = ImageId,
imageSource = ImageSource,
loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl,
weatherCity = WeatherCity,
dateCreation = DateCreation,
primaryColor = PrimaryColor,
languages = Languages,
secondaryColor = SecondaryColor,
isMobile = IsMobile,
isTablet = IsTablet,
isOffline = IsOffline,
sections = sections,
resources = resources,
instanceId = InstanceId,
isDate = IsDate,
isSectionImageBackground = IsSectionImageBackground,
roundedValue = RoundedValue,
screenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage,
sectionIds = sections.Select(s => s.id).ToList()
};
}
}
}