new photos controller created

This commit is contained in:
2024-09-25 22:11:28 +02:00
Unverified
parent bb67186587
commit 9e9e5e1742
36 changed files with 743 additions and 332 deletions

View File

@@ -0,0 +1,50 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Media;
namespace WatchIt.Common.Model.Photos;
public class PhotoResponse : Photo
{
#region PROPERTIES
[JsonPropertyName("id")]
public Guid Id { get; set; }
[JsonPropertyName("media_id")]
public required long MediaId { get; set; }
[JsonPropertyName("upload_date")]
public DateTime UploadDate { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public PhotoResponse() {}
[SetsRequiredMembers]
public PhotoResponse(MediaPhotoImage mediaPhotoImage)
{
Id = mediaPhotoImage.Id;
MediaId = mediaPhotoImage.MediaId;
Image = mediaPhotoImage.Image;
MimeType = mediaPhotoImage.MimeType;
UploadDate = mediaPhotoImage.UploadDate;
if (mediaPhotoImage.MediaPhotoImageBackground is not null)
{
Background = new PhotoBackgroundData
{
IsUniversalBackground = mediaPhotoImage.MediaPhotoImageBackground.IsUniversalBackground,
FirstGradientColor = mediaPhotoImage.MediaPhotoImageBackground.FirstGradientColor,
SecondGradientColor = mediaPhotoImage.MediaPhotoImageBackground.SecondGradientColor
};
}
}
#endregion
}