Added DTO for remaining models

This commit is contained in:
quentin 2024-04-22 17:55:47 -05:00
parent 99b3f65c97
commit 10cce72fbc
7 changed files with 207 additions and 0 deletions

View File

@ -1,4 +1,5 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base
{
@ -8,7 +9,10 @@ namespace API.DTO.Base
public byte red { get; set; }
public byte blue { get; set; }
public byte green { get; set; }
[MaxLength(64)]
public string name { get; set; } = null!;
public DateTime updated { get; set; }
public ulong updater { get; set; }
public Color adaptToModel()

37
API/DTO/Base/EventDTO.cs Normal file
View File

@ -0,0 +1,37 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base
{
public class EventDTO : IAdaptable<Event>
{
public ulong id { get; set; }
public ulong savedEventId { get; set; }
[MaxLength(64)]
public string? name { get; set; } = null!;
public ulong? bgColorId { get; set; }
public ulong? fgColorId { get; set; }
public ulong? imageId { get; set; }
public bool hidden { get; set; }
public DateTime updated { get; set; }
public ulong updater { get; set; }
public Event adaptToModel()
{
return new Event
{
id = id,
savedEventId = savedEventId,
name = name,
bgColorId = bgColorId,
fgColorId = fgColorId,
imageId = imageId,
hidden = hidden,
updated = updated,
updater = updater
};
}
}
}

31
API/DTO/Base/GrantDTO.cs Normal file
View File

@ -0,0 +1,31 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base
{
public class GrantDTO : IAdaptable<Grant>
{
public ulong id { get; set; }
[MaxLength(128)]
public string name { get; set; } = null!;
public ulong permissionId { get; set; }
public DateTime updated { get; set; }
public ulong updater { get; set; }
public Grant adaptToModel()
{
return new Grant
{
id = id,
name = name,
permissionId = permissionId,
updated = updated,
updater = updater
};
}
}
}

32
API/DTO/Base/ImageDTO.cs Normal file
View File

@ -0,0 +1,32 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base
{
public class ImageDTO : IAdaptable<Image>
{
public ulong id { get; set; }
[MaxLength(64)]
public string name { get; set; } = null!;
[MaxLength(128)]
public string filename { get; set; } = null!;
public DateTime updated { get; set; }
public ulong updater { get; set; }
public Image adaptToModel()
{
return new Image
{
id = id,
name = name,
filename = filename,
updated = updated,
updater = updater
};
}
}
}

View File

@ -0,0 +1,28 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base
{
public class PermissionDTO : IAdaptable<Permission>
{
public ulong id { get; set; }
[MaxLength(64)]
public string name { get; set; } = null!;
public DateTime updated { get; set; }
public ulong updater { get; set; }
public Permission adaptToModel()
{
return new Permission
{
id = id,
name = name,
updated = updated,
updater = updater
};
}
}
}

View File

@ -0,0 +1,37 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base
{
public class SavedEventDTO : IAdaptable<SavedEvent>
{
public ulong id { get; set; }
[MaxLength(64)]
public string name { get; set; } = null!;
public ulong bgColorId { get; set; }
public ulong fgColorId { get; set; }
public ulong? imageId { get; set; }
public DateTime updated { get; set; }
public ulong updater { get; set; }
public SavedEvent adaptToModel()
{
return new SavedEvent
{
id = id,
name = name,
bgColorId = bgColorId,
fgColorId = fgColorId,
imageId = imageId,
updated = updated,
updater = updater
};
}
}
}

38
API/DTO/Base/UserDTO.cs Normal file
View File

@ -0,0 +1,38 @@
using DAL.Models;
using System.ComponentModel.DataAnnotations;
namespace API.DTO.Base
{
public class UserDTO : IAdaptable<User>
{
public ulong id { get; set; }
[MaxLength(64)]
public string firstName { get; set; } = null!;
[MaxLength(64)]
public string lastName { get; set; } = null!;
public ulong phoneNumber { get; set; }
public ulong permissionId { get; set; }
public DateTime updated { get; set; }
public ulong updater { get; set; }
public User adaptToModel()
{
return new User
{
id = id,
firstName = firstName,
lastName = lastName,
phoneNumber = phoneNumber,
permissionId = permissionId,
updated = updated,
updater = updater
};
}
}
}