From 890c521675502b4846c72729ac098beb37afb205 Mon Sep 17 00:00:00 2001 From: quentin Date: Mon, 20 May 2024 10:44:49 -0500 Subject: [PATCH] Added ColorUpdateDTO.cs --- API/DTO/Base/Update/ColorUpdateDTO.cs | 23 +++++++++++++++++++++++ API/DTO/IUpdateAdaptable.cs | 7 +++++++ 2 files changed, 30 insertions(+) create mode 100644 API/DTO/Base/Update/ColorUpdateDTO.cs create mode 100644 API/DTO/IUpdateAdaptable.cs diff --git a/API/DTO/Base/Update/ColorUpdateDTO.cs b/API/DTO/Base/Update/ColorUpdateDTO.cs new file mode 100644 index 0000000..3b68996 --- /dev/null +++ b/API/DTO/Base/Update/ColorUpdateDTO.cs @@ -0,0 +1,23 @@ +using DAL.Models; +using System.ComponentModel.DataAnnotations; + +namespace API.DTO.Base.Update +{ + public class ColorUpdateDTO : IUpdateAdaptable + { + public byte? red { get; set; } + public byte? blue { get; set; } + public byte? green { get; set; } + + [MaxLength(64)] + public string? name { get; set; } + + public void adaptModel(ref Color model) + { + if (red != null) model.red = (byte)red; + if (blue != null) model.blue = (byte)blue; + if (green != null) model.green = (byte)green; + if (name != null) model.name = name; + } + } +} diff --git a/API/DTO/IUpdateAdaptable.cs b/API/DTO/IUpdateAdaptable.cs new file mode 100644 index 0000000..354eb26 --- /dev/null +++ b/API/DTO/IUpdateAdaptable.cs @@ -0,0 +1,7 @@ +namespace API.DTO +{ + public interface IUpdateAdaptable + { + void adaptModel(ref TModel model); + } +}