Update agenda sync (image management) + update isStatistics to hasStats (subscription plan)
This commit is contained in:
parent
9633ae43b7
commit
674655eb80
@ -53,7 +53,7 @@ namespace ManagerService.Controllers
|
||||
|
||||
return new OkObjectResult(applicationInstances.Select(ai => {
|
||||
var dto = ai.ToDTO(_myInfoMateDbContext);
|
||||
dto.isStatistic = instance?.IsStatistic ?? false;
|
||||
dto.hasStats = instance?.HasStats ?? false;
|
||||
return dto;
|
||||
}).OrderBy(c => c.appType));
|
||||
}
|
||||
|
||||
@ -190,7 +190,6 @@ namespace ManagerService.Controllers
|
||||
instance.Name = updatedInstance.name ?? instance.Name;
|
||||
instance.PinCode = updatedInstance.pinCode ?? instance.PinCode;
|
||||
instance.IsPushNotification = updatedInstance.isPushNotification ?? instance.IsPushNotification;
|
||||
instance.IsStatistic = updatedInstance.isStatistic ?? instance.IsStatistic;
|
||||
instance.IsMobile = updatedInstance.isMobile ?? instance.IsMobile;
|
||||
instance.IsTablet = updatedInstance.isTablet ?? instance.IsTablet;
|
||||
instance.IsWeb = updatedInstance.isWeb ?? instance.IsWeb;
|
||||
|
||||
@ -84,7 +84,7 @@ namespace ManagerService.Controllers
|
||||
[ProducesResponseType(typeof(string), 404)]
|
||||
[ProducesResponseType(typeof(string), 500)]
|
||||
[HttpGet("{sectionAgendaId}/events/upcoming")]
|
||||
public ObjectResult GetUpcomingEventAgendas(string sectionAgendaId)
|
||||
public ObjectResult GetUpcomingEventAgendas(string sectionAgendaId, [FromQuery] string? language = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -96,6 +96,7 @@ namespace ManagerService.Controllers
|
||||
var today = DateTime.Today;
|
||||
var upcoming = sectionAgenda.EventAgendas
|
||||
.Where(ea => ea.DateFrom == null || ea.DateFrom >= today)
|
||||
.Where(ea => language == null || ea.Label.Any(l => l.language == language))
|
||||
.OrderBy(ea => ea.DateFrom)
|
||||
.Select(ea => ea.ToDTO());
|
||||
|
||||
|
||||
@ -36,6 +36,6 @@ namespace ManagerService.DTOs
|
||||
|
||||
public bool isAssistant { get; set; }
|
||||
|
||||
public bool isStatistic { get; set; }
|
||||
public bool hasStats { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ namespace ManagerService.DTOs
|
||||
public DateTime? dateCreation { get; set; }
|
||||
public string pinCode { get; set; }
|
||||
public bool? isPushNotification { get; set; }
|
||||
public bool? isStatistic { get; set; }
|
||||
public bool? isMobile { get; set; }
|
||||
public bool? isTablet { get; set; }
|
||||
public bool? isWeb { get; set; }
|
||||
|
||||
@ -24,8 +24,6 @@ namespace ManagerService.Data
|
||||
|
||||
public bool IsPushNotification { get; set; }
|
||||
|
||||
public bool IsStatistic { get; set; }
|
||||
|
||||
public bool IsMobile { get; set; }
|
||||
|
||||
public bool IsTablet { get; set; }
|
||||
@ -69,7 +67,6 @@ namespace ManagerService.Data
|
||||
dateCreation = DateCreation,
|
||||
pinCode = PinCode,
|
||||
isPushNotification = IsPushNotification,
|
||||
isStatistic = IsStatistic,
|
||||
isMobile = IsMobile,
|
||||
isTablet = IsTablet,
|
||||
isWeb = IsWeb,
|
||||
@ -96,7 +93,6 @@ namespace ManagerService.Data
|
||||
DateCreation = instanceDTO.dateCreation != null ? instanceDTO.dateCreation.Value : DateTime.Now.ToUniversalTime();
|
||||
PinCode = instanceDTO.pinCode;
|
||||
IsPushNotification = instanceDTO.isPushNotification ?? false;
|
||||
IsStatistic = instanceDTO.isStatistic ?? false;
|
||||
IsMobile = instanceDTO.isMobile ?? false;
|
||||
IsTablet = instanceDTO.isTablet ?? false;
|
||||
IsWeb = instanceDTO.isWeb ?? false;
|
||||
|
||||
@ -38,6 +38,8 @@ namespace ManagerService.Data.SubSection
|
||||
|
||||
public Resource Resource { get; set; } // Background image
|
||||
|
||||
public string? SyncedImageUrl { get; set; } // External image URL from sync (no Resource record created)
|
||||
|
||||
public string? VideoResourceId { get; set; }
|
||||
|
||||
[ForeignKey("VideoResourceId")]
|
||||
@ -79,7 +81,7 @@ namespace ManagerService.Data.SubSection
|
||||
dateTo = DateTo,
|
||||
website = Website,
|
||||
resourceId = ResourceId,
|
||||
resource = Resource?.ToDTO(),
|
||||
resource = Resource?.ToDTO() ?? (SyncedImageUrl != null ? new ResourceDTO { url = SyncedImageUrl, type = ResourceType.ImageUrl } : null),
|
||||
videoResourceId = VideoResourceId,
|
||||
videoResource = VideoResource?.ToDTO(),
|
||||
address = Address != null ? new EventAddressDTO
|
||||
|
||||
1587
ManagerService/Migrations/20260507151944_AddEventAgendaSyncedImageUrl.Designer.cs
generated
Normal file
1587
ManagerService/Migrations/20260507151944_AddEventAgendaSyncedImageUrl.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ManagerService.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddEventAgendaSyncedImageUrl : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "SyncedImageUrl",
|
||||
table: "EventAgendas",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SyncedImageUrl",
|
||||
table: "EventAgendas");
|
||||
}
|
||||
}
|
||||
}
|
||||
1584
ManagerService/Migrations/20260507192701_RemoveIsStatistic.Designer.cs
generated
Normal file
1584
ManagerService/Migrations/20260507192701_RemoveIsStatistic.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ManagerService.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RemoveIsStatistic : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsStatistic",
|
||||
table: "Instances");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsStatistic",
|
||||
table: "Instances",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -363,9 +363,6 @@ namespace ManagerService.Migrations
|
||||
b.Property<bool>("IsPushNotification")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsStatistic")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsTablet")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
@ -608,6 +605,9 @@ namespace ManagerService.Migrations
|
||||
b.Property<string>("SectionEventId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("SyncedImageUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.HasColumnType("text");
|
||||
|
||||
|
||||
@ -51,7 +51,6 @@ namespace ManagerService.Services
|
||||
|
||||
var section = db.Sections.OfType<SectionAgenda>()
|
||||
.Include(sa => sa.EventAgendas)
|
||||
.ThenInclude(ea => ea.Resource)
|
||||
.FirstOrDefault(sa => sa.Id == sectionAgendaId);
|
||||
|
||||
if (section == null || !section.IsOnlineAgenda || section.AgendaResourceIds == null)
|
||||
@ -84,12 +83,13 @@ namespace ManagerService.Services
|
||||
{
|
||||
var dateFrom = remote.GetDateFrom();
|
||||
|
||||
// Match on DateFrom (date part only), restricted to IsSynced events
|
||||
// Match by date + name in the current language
|
||||
var existing = section.EventAgendas.FirstOrDefault(ea =>
|
||||
ea.IsSynced &&
|
||||
ea.DateFrom.HasValue &&
|
||||
dateFrom.HasValue &&
|
||||
ea.DateFrom.Value.Date == dateFrom.Value.Date);
|
||||
ea.DateFrom.Value.Date == dateFrom.Value.Date &&
|
||||
ea.Label.Any(l => l.language == resourceRef.language && l.value == remote.name));
|
||||
|
||||
if (existing == null)
|
||||
{
|
||||
@ -117,24 +117,8 @@ namespace ManagerService.Services
|
||||
existing.IdVideoYoutube = remote.id_video_youtube;
|
||||
existing.IsSynced = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(remote.image) && string.IsNullOrEmpty(existing.ResourceId))
|
||||
{
|
||||
var imageResource = db.Resources.FirstOrDefault(r => r.Url == remote.image && r.InstanceId == section.InstanceId);
|
||||
if (imageResource == null)
|
||||
{
|
||||
imageResource = new Resource
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
Type = ResourceType.ImageUrl,
|
||||
Label = remote.name ?? "agenda-image",
|
||||
Url = remote.image,
|
||||
InstanceId = section.InstanceId,
|
||||
DateCreation = DateTime.UtcNow,
|
||||
};
|
||||
db.Resources.Add(imageResource);
|
||||
}
|
||||
existing.ResourceId = imageResource.Id;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(remote.image) && string.IsNullOrEmpty(existing.SyncedImageUrl))
|
||||
existing.SyncedImageUrl = remote.image;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user