EventUpdateDTO when UnSettable

This commit is contained in:
quentin 2024-10-29 19:14:35 -05:00
parent 4fc88d90ce
commit 777fb1c4c9

View File

@ -1,5 +1,4 @@
using DAL.Models; using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base.Update namespace API.DTO.Base.Update
{ {
@ -7,23 +6,23 @@ namespace API.DTO.Base.Update
{ {
public ulong? savedEventId { get; set; } public ulong? savedEventId { get; set; }
[MaxLength(64)] // [MaxLength(64)]
public UnSettable<string?>? name { get; set; } public UnSettable<string?>? name { get; set; }
public UnSettable<ulong?>? bgColorId { get; set; } public UnSettable<ulong?>? bgColorId { get; set; }
public UnSettable<ulong?>? fgColorId { get; set; } public UnSettable<ulong?>? fgColorId { get; set; }
public UnSettable<ulong?>? imageId { get; set; } public UnSettable<ulong?>? imageId { get; set; }
public UnSettable<DateTime>? when { get; set; } public DateTime? when { get; set; }
public bool? hidden { get; set; } public bool? hidden { get; set; }
public void adaptModel(ref Event model) public void adaptModel(ref Event model)
{ {
if (savedEventId != null) model.savedEventId = (ulong)savedEventId; if (savedEventId != null) model.savedEventId = (ulong)savedEventId;
if (name != null) model.name = ((UnSettable<string?>)name).value; if (name != null) model.name = name.Value.value;
if (bgColorId != null) model.bgColorId = bgColorId.Value.value; if (bgColorId != null) model.bgColorId = bgColorId.Value.value;
if (fgColorId != null) model.bgColorId = fgColorId.Value.value; if (fgColorId != null) model.fgColorId = fgColorId.Value.value;
if (imageId != null) model.imageId = imageId.Value.value; if (imageId != null) model.imageId = imageId.Value.value;
if (when != null) model.when = when.Value.value; if (when != null) model.when = (DateTime)when;
if (hidden != null) model.hidden = (bool)hidden; if (hidden != null) model.hidden = (bool)hidden;
} }
} }