Created missing UpdateDTOS

This commit is contained in:
quentin 2024-05-20 15:00:47 -05:00
parent e5522ed559
commit 2a99a5ba62
7 changed files with 141 additions and 0 deletions

View File

@ -0,0 +1,28 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base.Update
{
public class EventUpdateDTO : IUpdateAdaptable<Event>
{
public ulong? savedEventId { get; set; }
[MaxLength(64)]
public UnSettable<string?>? name { get; set; }
public UnSettable<ulong?>? bgColorId { get; set; }
public UnSettable<ulong?>? fgColorId { get; set; }
public UnSettable<ulong?>? 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<string?>)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;
}
}
}

View File

@ -0,0 +1,19 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base.Update
{
public class GrantUpdateDTO : IUpdateAdaptable<Grant>
{
[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;
}
}
}

View File

@ -0,0 +1,20 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base.Update
{
public class ImageUpdateDTO : IUpdateAdaptable<Image>
{
[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;
}
}
}

View File

@ -0,0 +1,16 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base.Update
{
public class PermissionUpdateDTO : IUpdateAdaptable<Permission>
{
[MaxLength(64)]
public string? name { get; set; }
public void adaptModel(ref Permission model)
{
if (name != null) model.name = name;
}
}
}

View File

@ -0,0 +1,25 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base.Update
{
public class SavedEventUpdateDTO : IUpdateAdaptable<SavedEvent>
{
[MaxLength(64)]
public string? name { get; set; }
public ulong? bgColorId { get; set; }
public ulong? fgColorId { get; set; }
public UnSettable<ulong?>? 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;
}
}
}

View File

@ -0,0 +1,26 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base.Update
{
public class UserUpdateDTO : IUpdateAdaptable<User>
{
[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;
}
}
}

7
API/DTO/UnSettable.cs Normal file
View File

@ -0,0 +1,7 @@
namespace API.DTO
{
public struct UnSettable<T>
{
public T value { get; set; }
}
}