From 2a99a5ba62a5ccc16fd3797048510f79a313fb0f Mon Sep 17 00:00:00 2001 From: quentin Date: Mon, 20 May 2024 15:00:47 -0500 Subject: [PATCH] Created missing UpdateDTOS --- API/DTO/Base/Update/EventUpdateDTO.cs | 28 ++++++++++++++++++++++ API/DTO/Base/Update/GrantUpdateDTO.cs | 19 +++++++++++++++ API/DTO/Base/Update/ImageUpdateDTO.cs | 20 ++++++++++++++++ API/DTO/Base/Update/PermissionUpdateDTO.cs | 16 +++++++++++++ API/DTO/Base/Update/SavedEventUpdateDTO.cs | 25 +++++++++++++++++++ API/DTO/Base/Update/UserUpdateDTO.cs | 26 ++++++++++++++++++++ API/DTO/UnSettable.cs | 7 ++++++ 7 files changed, 141 insertions(+) create mode 100644 API/DTO/Base/Update/EventUpdateDTO.cs create mode 100644 API/DTO/Base/Update/GrantUpdateDTO.cs create mode 100644 API/DTO/Base/Update/ImageUpdateDTO.cs create mode 100644 API/DTO/Base/Update/PermissionUpdateDTO.cs create mode 100644 API/DTO/Base/Update/SavedEventUpdateDTO.cs create mode 100644 API/DTO/Base/Update/UserUpdateDTO.cs create mode 100644 API/DTO/UnSettable.cs diff --git a/API/DTO/Base/Update/EventUpdateDTO.cs b/API/DTO/Base/Update/EventUpdateDTO.cs new file mode 100644 index 0000000..d48e443 --- /dev/null +++ b/API/DTO/Base/Update/EventUpdateDTO.cs @@ -0,0 +1,28 @@ +using DAL.Models; +using System.ComponentModel.DataAnnotations; + +namespace API.DTO.Base.Update +{ + public class EventUpdateDTO : IUpdateAdaptable + { + public ulong? savedEventId { get; set; } + + [MaxLength(64)] + public UnSettable? name { get; set; } + + public UnSettable? bgColorId { get; set; } + public UnSettable? fgColorId { get; set; } + public UnSettable? imageId { get; set; } + public bool? hidden { get; set; } + + public void adaptModel(ref Event model) + { + if (savedEventId != null) model.savedEventId = (ulong)savedEventId; + if (name != null) model.name = ((UnSettable)name).value; + if (bgColorId != null) model.bgColorId = bgColorId.Value.value; + if (fgColorId != null) model.bgColorId = fgColorId.Value.value; + if (imageId != null) model.imageId = imageId.Value.value; + if (hidden != null) model.hidden = (bool)hidden; + } + } +} diff --git a/API/DTO/Base/Update/GrantUpdateDTO.cs b/API/DTO/Base/Update/GrantUpdateDTO.cs new file mode 100644 index 0000000..fb1ee8d --- /dev/null +++ b/API/DTO/Base/Update/GrantUpdateDTO.cs @@ -0,0 +1,19 @@ +using DAL.Models; +using System.ComponentModel.DataAnnotations; + +namespace API.DTO.Base.Update +{ + public class GrantUpdateDTO : IUpdateAdaptable + { + [MaxLength(128)] + public string? name { get; set; } + + public ulong? permissionId { get; set; } + + public void adaptModel(ref Grant model) + { + if (name != null) model.name = name; + if (permissionId != null) model.permissionId = (ulong)permissionId; + } + } +} diff --git a/API/DTO/Base/Update/ImageUpdateDTO.cs b/API/DTO/Base/Update/ImageUpdateDTO.cs new file mode 100644 index 0000000..ad2f5eb --- /dev/null +++ b/API/DTO/Base/Update/ImageUpdateDTO.cs @@ -0,0 +1,20 @@ +using DAL.Models; +using System.ComponentModel.DataAnnotations; + +namespace API.DTO.Base.Update +{ + public class ImageUpdateDTO : IUpdateAdaptable + { + [MaxLength(64)] + public string? name { get; set; } + + [MaxLength(128)] + public string? filename { get; set; } + + public void adaptModel(ref Image model) + { + if (name != null) model.name = name; + if (filename != null) model.filename = filename; + } + } +} diff --git a/API/DTO/Base/Update/PermissionUpdateDTO.cs b/API/DTO/Base/Update/PermissionUpdateDTO.cs new file mode 100644 index 0000000..e396e87 --- /dev/null +++ b/API/DTO/Base/Update/PermissionUpdateDTO.cs @@ -0,0 +1,16 @@ +using DAL.Models; +using System.ComponentModel.DataAnnotations; + +namespace API.DTO.Base.Update +{ + public class PermissionUpdateDTO : IUpdateAdaptable + { + [MaxLength(64)] + public string? name { get; set; } + + public void adaptModel(ref Permission model) + { + if (name != null) model.name = name; + } + } +} diff --git a/API/DTO/Base/Update/SavedEventUpdateDTO.cs b/API/DTO/Base/Update/SavedEventUpdateDTO.cs new file mode 100644 index 0000000..3ab132d --- /dev/null +++ b/API/DTO/Base/Update/SavedEventUpdateDTO.cs @@ -0,0 +1,25 @@ +using DAL.Models; +using System.ComponentModel.DataAnnotations; + +namespace API.DTO.Base.Update +{ + public class SavedEventUpdateDTO : IUpdateAdaptable + { + [MaxLength(64)] + public string? name { get; set; } + + public ulong? bgColorId { get; set; } + + public ulong? fgColorId { get; set; } + + public UnSettable? imageId { get; set; } + + public void adaptModel(ref SavedEvent model) + { + if (name != null) model.name = name; + if (bgColorId != null) model.bgColorId = (ulong)bgColorId; + if (fgColorId != null) model.fgColorId = (ulong)fgColorId; + if (imageId != null) model.imageId = imageId.Value.value; + } + } +} diff --git a/API/DTO/Base/Update/UserUpdateDTO.cs b/API/DTO/Base/Update/UserUpdateDTO.cs new file mode 100644 index 0000000..2244d6c --- /dev/null +++ b/API/DTO/Base/Update/UserUpdateDTO.cs @@ -0,0 +1,26 @@ +using DAL.Models; +using System.ComponentModel.DataAnnotations; + +namespace API.DTO.Base.Update +{ + public class UserUpdateDTO : IUpdateAdaptable + { + [MaxLength(64)] + public string? firstName { get; set; } + + [MaxLength(64)] + public string? lastName { get; set; } + + public ulong? phoneNumber { get; set; } + + public ulong? permissionId { get; set; } + + public void adaptModel(ref User model) + { + if (firstName != null) model.firstName = firstName; + if (lastName != null) model.lastName = lastName; + if (phoneNumber != null) model.phoneNumber = (ulong)phoneNumber; + if (permissionId != null) model.permissionId = (ulong)permissionId; + } + } +} diff --git a/API/DTO/UnSettable.cs b/API/DTO/UnSettable.cs new file mode 100644 index 0000000..da69d2a --- /dev/null +++ b/API/DTO/UnSettable.cs @@ -0,0 +1,7 @@ +namespace API.DTO +{ + public struct UnSettable + { + public T value { get; set; } + } +}