2025-03-19 08:57:29 +01:00

66 lines
2.0 KiB
C#

using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section puzzle
/// </summary>
public class SectionPuzzle : Section
{
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationAndResource> MessageDebut { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationAndResource> MessageFin { get; set; }
public string ContentId { get; set; } // But only image is possible
public Content Content { get; set; } // But only image is possible
[Required]
public int Rows { get; set; } = 3;
[Required]
public int Cols { get; set; } = 3;
public PuzzleDTO ToDTO()
{
return new PuzzleDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
messageDebut = MessageDebut.Select(md => md.ToDTO()).ToList(),
messageFin = MessageFin.Select(mf => mf.ToDTO()).ToList(),
image = Content.ToDTO(),
rows = Rows,
cols = Cols
};
}
}
}