Created missing UpdateDTOS
This commit is contained in:
parent
e5522ed559
commit
2a99a5ba62
28
API/DTO/Base/Update/EventUpdateDTO.cs
Normal file
28
API/DTO/Base/Update/EventUpdateDTO.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
19
API/DTO/Base/Update/GrantUpdateDTO.cs
Normal file
19
API/DTO/Base/Update/GrantUpdateDTO.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
20
API/DTO/Base/Update/ImageUpdateDTO.cs
Normal file
20
API/DTO/Base/Update/ImageUpdateDTO.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
16
API/DTO/Base/Update/PermissionUpdateDTO.cs
Normal file
16
API/DTO/Base/Update/PermissionUpdateDTO.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
25
API/DTO/Base/Update/SavedEventUpdateDTO.cs
Normal file
25
API/DTO/Base/Update/SavedEventUpdateDTO.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
26
API/DTO/Base/Update/UserUpdateDTO.cs
Normal file
26
API/DTO/Base/Update/UserUpdateDTO.cs
Normal 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
7
API/DTO/UnSettable.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace API.DTO
|
||||
{
|
||||
public struct UnSettable<T>
|
||||
{
|
||||
public T value { get; set; }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user