Merge pull request #175 from mateuszskoczek/dev/0.5.0

Dev/0.5.0
This commit is contained in:
2025-03-03 01:41:31 +01:00
committed by GitHub
Unverified
905 changed files with 22027 additions and 27421 deletions

View File

@@ -1,4 +1,4 @@
next-version: 0.4.0 next-version: 0.5.0
assembly-versioning-scheme: MajorMinorPatch assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch assembly-file-versioning-scheme: MajorMinorPatch

View File

@@ -17,7 +17,7 @@ jobs:
- name: Setup .NET - name: Setup .NET
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: 8.0.x dotnet-version: 9.0.x
- name: Restore dependencies - name: Restore dependencies
run: dotnet restore run: dotnet restore
- name: Build - name: Build

View File

@@ -17,7 +17,7 @@ jobs:
- name: Setup .NET - name: Setup .NET
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: 8.0.x dotnet-version: 9.0.x
- name: Restore dependencies - name: Restore dependencies
run: dotnet restore run: dotnet restore
- name: Build - name: Build

View File

@@ -15,7 +15,7 @@ jobs:
- name: Setup .NET - name: Setup .NET
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: 8.0.x dotnet-version: 9.0.x
- name: Restore dependencies - name: Restore dependencies
run: dotnet restore run: dotnet restore
- name: Build solution - name: Build solution
@@ -42,4 +42,4 @@ jobs:
with: with:
string: ${{ matrix.app }} string: ${{ matrix.app }}
- name: Build image - name: Build image
run: docker build ${{ github.workspace }} -t ghcr.io/${{github.actor}}/${{ steps.name.outputs.lowercase }}:build-test -f ${{ github.workspace }}/${{ matrix.app }}/${{ matrix.app }}/Dockerfile run: docker build ${{ github.workspace }} -t ghcr.io/${{github.actor}}/${{ steps.name.outputs.lowercase }}:build-test -f ${{ github.workspace }}/${{ matrix.app }}/Dockerfile

View File

@@ -33,7 +33,7 @@ jobs:
uses: microsoft/variable-substitution@v1 uses: microsoft/variable-substitution@v1
if: ${{ matrix.app == 'WatchIt.WebAPI' }} if: ${{ matrix.app == 'WatchIt.WebAPI' }}
with: with:
files: ${{ github.workspace }}/${{ matrix.app }}/${{ matrix.app }}/appsettings.json files: ${{ github.workspace }}/${{ matrix.app }}/appsettings.json
env: env:
ConnectionStrings.Default: ${{ secrets.CONNECTION_STRING }} ConnectionStrings.Default: ${{ secrets.CONNECTION_STRING }}
RootUser.Email: ${{ secrets.ROOT_EMAIL }} RootUser.Email: ${{ secrets.ROOT_EMAIL }}
@@ -43,7 +43,7 @@ jobs:
uses: microsoft/variable-substitution@v1 uses: microsoft/variable-substitution@v1
if: ${{ matrix.app == 'WatchIt.Website' }} if: ${{ matrix.app == 'WatchIt.Website' }}
with: with:
files: ${{ github.workspace }}/${{ matrix.app }}/${{ matrix.app }}/appsettings.json files: ${{ github.workspace }}/${{ matrix.app }}/appsettings.json
env: env:
Endpoints.Base: ${{ secrets.API_URL }} Endpoints.Base: ${{ secrets.API_URL }}
- name: Set up Docker Buildx - name: Set up Docker Buildx
@@ -60,7 +60,7 @@ jobs:
with: with:
string: ${{ matrix.app }} string: ${{ matrix.app }}
- name: Build image - name: Build image
run: docker build ${{ github.workspace }} -t ghcr.io/${{github.actor}}/${{ steps.name.outputs.lowercase }}:latest -t ghcr.io/${{github.actor}}/${{ steps.name.outputs.lowercase }}:${{steps.gitversion.outputs.SemVer}} -f ${{ github.workspace }}/${{ matrix.app }}/${{ matrix.app }}/Dockerfile run: docker build ${{ github.workspace }} -t ghcr.io/${{github.actor}}/${{ steps.name.outputs.lowercase }}:latest -t ghcr.io/${{github.actor}}/${{ steps.name.outputs.lowercase }}:${{steps.gitversion.outputs.SemVer}} -f ${{ github.workspace }}/${{ matrix.app }}/Dockerfile
- name: Publish image - name: Publish image
run: docker push ghcr.io/${{github.actor}}/${{ steps.name.outputs.lowercase }} --all-tags run: docker push ghcr.io/${{github.actor}}/${{ steps.name.outputs.lowercase }} --all-tags
outputs: outputs:
@@ -83,6 +83,7 @@ jobs:
name: Deploy name: Deploy
runs-on: watchit runs-on: watchit
needs: publish needs: publish
if: false
steps: steps:
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v1 uses: docker/login-action@v1

View File

@@ -1 +0,0 @@
# WatchIt

View File

@@ -1,19 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public abstract class Account
{
#region PROPERTIES
[JsonPropertyName("username")]
public required string Username { get; set; }
[JsonPropertyName("email")]
public required string Email { get; set; }
[JsonPropertyName("description")]
public string? Description { get; set; }
#endregion
}

View File

@@ -1,27 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public class AccountEmailRequest
{
#region PROPERTIES
[JsonPropertyName("new_email")]
public string NewEmail { get; set; }
[JsonPropertyName("password")]
public string Password { get; set; }
#endregion
#region PUBLIC METHODS
public void UpdateAccount(Database.Model.Account.Account account)
{
account.Email = NewEmail;
}
#endregion
}

View File

@@ -1,19 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public class AccountPasswordRequest
{
#region PROPERTIES
[JsonPropertyName("old_password")]
public string OldPassword { get; set; }
[JsonPropertyName("new_password")]
public string NewPassword { get; set; }
[JsonPropertyName("new_password_confirmation")]
public string NewPasswordConfirmation { get; set; }
#endregion
}

View File

@@ -1,26 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public class AccountProfileBackgroundRequest
{
#region PROPERTIES
[JsonPropertyName("id")]
public required Guid Id { get; set; }
#endregion
#region CONSTRUCTORS
[SetsRequiredMembers]
public AccountProfileBackgroundRequest(Guid id)
{
Id = id;
}
#endregion
}

View File

@@ -1,42 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public class AccountProfileInfoRequest
{
#region PROPERTIES
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonPropertyName("gender_id")]
public short? GenderId { get; set; }
#endregion
#region CONSTRUCTORS
public AccountProfileInfoRequest() { }
public AccountProfileInfoRequest(AccountResponse accountResponse)
{
Description = accountResponse.Description;
GenderId = accountResponse.Gender?.Id;
}
#endregion
#region PUBLIC METHODS
public void UpdateAccount(Database.Model.Account.Account account)
{
account.Description = Description;
account.GenderId = GenderId;
}
#endregion
}

View File

@@ -1,13 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public abstract class AccountProfilePicture : Picture
{
#region CONSTRUCTORS
[JsonConstructor]
public AccountProfilePicture() {}
#endregion
}

View File

@@ -1,33 +0,0 @@
using System.Diagnostics.CodeAnalysis;
namespace WatchIt.Common.Model.Accounts;
public class AccountProfilePictureRequest : AccountProfilePicture
{
#region CONSTRUCTORS
public AccountProfilePictureRequest() {}
[SetsRequiredMembers]
public AccountProfilePictureRequest(Picture image)
{
Image = image.Image;
MimeType = image.MimeType;
}
#endregion
public Database.Model.Account.AccountProfilePicture CreateMediaPosterImage() => new Database.Model.Account.AccountProfilePicture
{
Image = Image,
MimeType = MimeType,
};
public void UpdateMediaPosterImage(Database.Model.Account.AccountProfilePicture item)
{
item.Image = Image;
item.MimeType = MimeType;
item.UploadDate = DateTime.UtcNow;
}
}

View File

@@ -1,35 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public class AccountProfilePictureResponse : AccountProfilePicture
{
#region PROPERTIES
[JsonPropertyName("id")]
public required Guid Id { get; set; }
[JsonPropertyName("upload_date")]
public required DateTime UploadDate { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public AccountProfilePictureResponse() {}
[SetsRequiredMembers]
public AccountProfilePictureResponse(Database.Model.Account.AccountProfilePicture accountProfilePicture)
{
Id = accountProfilePicture.Id;
Image = accountProfilePicture.Image;
MimeType = accountProfilePicture.MimeType;
UploadDate = accountProfilePicture.UploadDate;
}
#endregion
}

View File

@@ -1,67 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Accounts;
public class AccountQueryParameters : QueryParameters<AccountResponse>
{
#region PROPERTIES
[FromQuery(Name = "username")]
public string? Username { get; set; }
[FromQuery(Name = "email")]
public string? Email { get; set; }
[FromQuery(Name = "description")]
public string? Description { get; set; }
[FromQuery(Name = "gender_id")]
public short? GenderId { get; set; }
[FromQuery(Name = "last_active")]
public DateOnly? LastActive { get; set; }
[FromQuery(Name = "last_active_from")]
public DateOnly? LastActiveFrom { get; set; }
[FromQuery(Name = "last_active_to")]
public DateOnly? LastActiveTo { get; set; }
[FromQuery(Name = "creation_date")]
public DateOnly? CreationDate { get; set; }
[FromQuery(Name = "creation_date_from")]
public DateOnly? CreationDateFrom { get; set; }
[FromQuery(Name = "creation_date_to")]
public DateOnly? CreationDateTo { get; set; }
[FromQuery(Name = "is_admin")]
public bool? IsAdmin { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(AccountResponse item) =>
(
TestStringWithRegex(item.Username, Username)
&&
TestStringWithRegex(item.Email, Email)
&&
TestStringWithRegex(item.Description, Description)
&&
Test(item.Gender?.Id, GenderId)
&&
TestComparable(item.LastActive, LastActive, LastActiveFrom, LastActiveTo)
&&
TestComparable(item.CreationDate, CreationDate, CreationDateFrom, CreationDateTo)
&&
Test(item.IsAdmin, IsAdmin)
);
#endregion
}

View File

@@ -1,64 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Model.Genders;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Accounts;
public class AccountResponse : Account, IQueryOrderable<AccountResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<AccountResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<AccountResponse, IComparable>>
{
{ "id", x => x.Id },
{ "username", x => x.Username },
{ "email", x => x.Email },
{ "description", x => x.Description },
{ "gender", x => x.Gender.Name },
{ "last_active", x => x.LastActive },
{ "creation_date", x => x.CreationDate },
{ "is_admin", x => x.IsAdmin }
};
[JsonPropertyName("id")]
public required long Id { get; set; }
[JsonPropertyName("gender")]
public GenderResponse? Gender { get; set; }
[JsonPropertyName("last_active")]
public DateTime LastActive { get; set; }
[JsonPropertyName("creation_date")]
public DateTime CreationDate { get; set; }
[JsonPropertyName("is_admin")]
public bool IsAdmin { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public AccountResponse() {}
[SetsRequiredMembers]
public AccountResponse(Database.Model.Account.Account account)
{
Id = account.Id;
Username = account.Username;
Email = account.Email;
Description = account.Description;
Gender = account.Gender is not null ? new GenderResponse(account.Gender) : null;
LastActive = account.LastActive;
CreationDate = account.CreationDate;
IsAdmin = account.IsAdmin;
}
#endregion
}

View File

@@ -1,27 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public class AccountUsernameRequest
{
#region PROPERTIES
[JsonPropertyName("new_username")]
public string NewUsername { get; set; }
[JsonPropertyName("password")]
public string Password { get; set; }
#endregion
#region PUBLIC METHODS
public void UpdateAccount(Database.Model.Account.Account account)
{
account.Username = NewUsername;
}
#endregion
}

View File

@@ -1,19 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public class AuthenticateRequest
{
#region PROPERTIES
[JsonPropertyName("username_or_email")]
public required string UsernameOrEmail { get; set; }
[JsonPropertyName("password")]
public required string Password { get; set; }
[JsonPropertyName("remember_me")]
public bool RememberMe { get; set; }
#endregion
}

View File

@@ -1,16 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public class AuthenticateResponse
{
#region PROPERTIES
[JsonPropertyName("access_token")]
public required string AccessToken { get; init; }
[JsonPropertyName("refresh_token")]
public required string RefreshToken { get; init; }
#endregion
}

View File

@@ -1,15 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Accounts;
public class RegisterRequest
{
[JsonPropertyName("username")]
public required string Username { get; set; }
[JsonPropertyName("email")]
public required string Email { get; set; }
[JsonPropertyName("password")]
public required string Password { get; set; }
}

View File

@@ -1,42 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Account;
namespace WatchIt.Common.Model.Accounts;
public class RegisterResponse
{
#region PROPERTIES
[JsonPropertyName("id")]
public required long Id { get; init; }
[JsonPropertyName("username")]
public required string Username { get; init; }
[JsonPropertyName("email")]
public required string Email { get; init; }
[JsonPropertyName("creation_date")]
public required DateTime CreationDate { get; init; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public RegisterResponse() {}
[SetsRequiredMembers]
public RegisterResponse(Database.Model.Account.Account account)
{
Id = account.Id;
Username = account.Username;
Email = account.Email;
CreationDate = account.CreationDate;
}
#endregion
}

View File

@@ -1,13 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Genders;
public class Gender
{
#region PROPERTIES
[JsonPropertyName("name")]
public required string Name { get; set; }
#endregion
}

View File

@@ -1,22 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Genders;
public class GenderQueryParameters : QueryParameters<GenderResponse>
{
#region PROPERTIES
[FromQuery(Name = "name")]
public string? Name { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(GenderResponse item) => TestStringWithRegex(item.Name, Name);
#endregion
}

View File

@@ -1,13 +0,0 @@
namespace WatchIt.Common.Model.Genders;
public class GenderRequest : Gender
{
#region PUBLIC METHODS
public Database.Model.Common.Gender CreateGender() => new Database.Model.Common.Gender()
{
Name = Name
};
#endregion
}

View File

@@ -1,38 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Genders;
public class GenderResponse : Gender, IQueryOrderable<GenderResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<GenderResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<GenderResponse, IComparable>>
{
{ "name", item => item.Name }
};
[JsonPropertyName("id")]
public required short? Id { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public GenderResponse() { }
[SetsRequiredMembers]
public GenderResponse(Database.Model.Common.Gender gender)
{
Id = gender.Id;
Name = gender.Name;
}
#endregion
}

View File

@@ -1,12 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Genres;
public class Genre
{
[JsonPropertyName("name")]
public required string Name { get; set; }
[JsonPropertyName("description")]
public string? Description { get; set; }
}

View File

@@ -1,30 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Genres;
public class GenreQueryParameters : QueryParameters<GenreResponse>
{
#region PROPERTIES
[FromQuery(Name = "name")]
public string? Name { get; set; }
[FromQuery(Name = "description")]
public string? Description { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(GenreResponse item) =>
(
TestStringWithRegex(item.Name, Name)
&&
TestStringWithRegex(item.Description, Description)
);
#endregion
}

View File

@@ -1,20 +0,0 @@
namespace WatchIt.Common.Model.Genres;
public class GenreRequest : Genre
{
#region PUBLIC METHODS
public Database.Model.Common.Genre CreateGenre() => new Database.Model.Common.Genre
{
Name = Name,
Description = Description,
};
public void UpdateGenre(Database.Model.Common.Genre genre)
{
genre.Name = Name;
genre.Description = Description;
}
#endregion
}

View File

@@ -1,41 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Genres;
public class GenreResponse : Genre, IQueryOrderable<GenreResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<GenreResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<GenreResponse, IComparable>>
{
{ "id", x => x.Id },
{ "name", x => x.Name },
{ "description", x => x.Description }
};
[JsonPropertyName("id")]
public short Id { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public GenreResponse() {}
[SetsRequiredMembers]
public GenreResponse(Database.Model.Common.Genre genre)
{
Id = genre.Id;
Name = genre.Name;
Description = genre.Description;
}
#endregion
}

View File

@@ -1,21 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Media;
public abstract class Media
{
[JsonPropertyName("title")]
public required string Title { get; set; }
[JsonPropertyName("original_title")]
public string? OriginalTitle { get; set; }
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonPropertyName("release_date")]
public DateOnly? ReleaseDate { get; set; }
[JsonPropertyName("length")]
public short? Length { get; set; }
}

View File

@@ -1,42 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using WatchIt.Common.Model.Photos;
using WatchIt.Database.Model.Media;
namespace WatchIt.Common.Model.Media;
public class MediaPhotoRequest : Photo
{
#region CONSTRUCTORS
public MediaPhotoRequest() {}
[SetsRequiredMembers]
public MediaPhotoRequest(PhotoResponse response)
{
Image = response.Image;
MimeType = response.MimeType;
}
#endregion
#region PUBLIC METHODS
public MediaPhotoImage CreateMediaPhotoImage(long mediaId) => new MediaPhotoImage
{
MediaId = mediaId,
Image = Image,
MimeType = MimeType
};
public MediaPhotoImageBackground? CreateMediaPhotoImageBackground(Guid mediaPhotoImageId) => Background is null ? null : new MediaPhotoImageBackground
{
Id = mediaPhotoImageId,
IsUniversalBackground = Background.IsUniversalBackground,
FirstGradientColor = Background.FirstGradientColor,
SecondGradientColor = Background.SecondGradientColor
};
#endregion
}

View File

@@ -1,7 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Media;
public abstract class MediaPoster : Picture
{
}

View File

@@ -1,34 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using WatchIt.Database.Model.Media;
namespace WatchIt.Common.Model.Media;
public class MediaPosterRequest : MediaPoster
{
#region CONSTRUCTORS
public MediaPosterRequest() {}
[SetsRequiredMembers]
public MediaPosterRequest(Picture image)
{
Image = image.Image;
MimeType = image.MimeType;
}
#endregion
public MediaPosterImage CreateMediaPosterImage() => new MediaPosterImage
{
Image = Image,
MimeType = MimeType,
};
public void UpdateMediaPosterImage(MediaPosterImage item)
{
item.Image = Image;
item.MimeType = MimeType;
item.UploadDate = DateTime.UtcNow;
}
}

View File

@@ -1,36 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Media;
namespace WatchIt.Common.Model.Media;
public class MediaPosterResponse : MediaPoster
{
#region PROPERTIES
[JsonPropertyName("id")]
public Guid Id { get; set; }
[JsonPropertyName("upload_date")]
public DateTime UploadDate { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public MediaPosterResponse() {}
[SetsRequiredMembers]
public MediaPosterResponse(MediaPosterImage mediaPhotoImage)
{
Id = mediaPhotoImage.Id;
Image = mediaPhotoImage.Image;
MimeType = mediaPhotoImage.MimeType;
UploadDate = mediaPhotoImage.UploadDate;
}
#endregion
}

View File

@@ -1,89 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Media;
public class MediaQueryParameters : QueryParameters<MediaResponse>
{
#region PROPERTIES
[FromQuery(Name = "type")]
public MediaType? Type { get; set; }
[FromQuery(Name = "title")]
public string? Title { get; set; }
[FromQuery(Name = "original_title")]
public string? OriginalTitle { get; set; }
[FromQuery(Name = "description")]
public string? Description { get; set; }
[FromQuery(Name = "release_date")]
public DateOnly? ReleaseDate { get; set; }
[FromQuery(Name = "release_date_from")]
public DateOnly? ReleaseDateFrom { get; set; }
[FromQuery(Name = "release_date_to")]
public DateOnly? ReleaseDateTo { get; set; }
[FromQuery(Name = "length")]
public short? Length { get; set; }
[FromQuery(Name = "length_from")]
public short? LengthFrom { get; set; }
[FromQuery(Name = "length_to")]
public short? LengthTo { get; set; }
[FromQuery(Name = "rating_average")]
public decimal? RatingAverage { get; set; }
[FromQuery(Name = "rating_average_from")]
public decimal? RatingAverageFrom { get; set; }
[FromQuery(Name = "rating_average_to")]
public decimal? RatingAverageTo { get; set; }
[FromQuery(Name = "rating_count")]
public long? RatingCount { get; set; }
[FromQuery(Name = "rating_count_from")]
public long? RatingCountFrom { get; set; }
[FromQuery(Name = "rating_count_to")]
public long? RatingCountTo { get; set; }
[FromQuery(Name = "genre")]
public IEnumerable<short>? Genres { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(MediaResponse item) =>
(
Test(item.Type, Type)
&&
TestStringWithRegex(item.Title, Title)
&&
TestStringWithRegex(item.OriginalTitle, OriginalTitle)
&&
TestStringWithRegex(item.Description, Description)
&&
TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo)
&&
TestComparable(item.Length, Length, LengthFrom, LengthTo)
&&
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
&&
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
&&
TestContains(Genres, item.Genres.Select(x => x.Id))
);
#endregion
}

View File

@@ -1,66 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Model.Genres;
using WatchIt.Common.Model.Rating;
using WatchIt.Common.Query;
using WatchIt.Database.Model.Rating;
namespace WatchIt.Common.Model.Media;
public class MediaResponse : Media, IQueryOrderable<MediaResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<MediaResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<MediaResponse, IComparable>>
{
{ "id", x => x.Id },
{ "title", x => x.Title },
{ "original_title", x => x.OriginalTitle },
{ "description", x => x.Description },
{ "release_date", x => x.ReleaseDate },
{ "length", x => x.Length },
{ "rating.average", x => x.Rating.Average },
{ "rating.count", x => x.Rating.Count }
};
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonPropertyName("type")]
public MediaType Type { get; set; }
[JsonPropertyName("rating")]
public RatingResponse Rating { get; set; }
[JsonPropertyName("genres")]
public IEnumerable<GenreResponse> Genres { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public MediaResponse() {}
[SetsRequiredMembers]
public MediaResponse(Database.Model.Media.Media media, MediaType mediaType)
{
Id = media.Id;
Title = media.Title;
OriginalTitle = media.OriginalTitle;
Description = media.Description;
ReleaseDate = media.ReleaseDate;
Length = media.Length;
Type = mediaType;
Rating = RatingResponseBuilder.Initialize()
.Add(media.RatingMedia, x => x.Rating)
.Build();
Genres = media.Genres.Select(x => new GenreResponse(x)).ToList();
}
#endregion
}

View File

@@ -1,7 +0,0 @@
namespace WatchIt.Common.Model.Media;
public enum MediaType
{
Movie,
Series
}

View File

@@ -1,9 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Movies;
public class Movie : Media.Media
{
[JsonPropertyName("budget")]
public decimal? Budget { get; set; }
}

View File

@@ -1,95 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Movies;
public class MovieQueryParameters : QueryParameters<MovieResponse>
{
#region PROPERTIES
[FromQuery(Name = "title")]
public string? Title { get; set; }
[FromQuery(Name = "original_title")]
public string? OriginalTitle { get; set; }
[FromQuery(Name = "description")]
public string? Description { get; set; }
[FromQuery(Name = "release_date")]
public DateOnly? ReleaseDate { get; set; }
[FromQuery(Name = "release_date_from")]
public DateOnly? ReleaseDateFrom { get; set; }
[FromQuery(Name = "release_date_to")]
public DateOnly? ReleaseDateTo { get; set; }
[FromQuery(Name = "length")]
public short? Length { get; set; }
[FromQuery(Name = "length_from")]
public short? LengthFrom { get; set; }
[FromQuery(Name = "length_to")]
public short? LengthTo { get; set; }
[FromQuery(Name = "budget")]
public decimal? Budget { get; set; }
[FromQuery(Name = "budget_from")]
public decimal? BudgetFrom { get; set; }
[FromQuery(Name = "budget_to")]
public decimal? BudgetTo { get; set; }
[FromQuery(Name = "rating_average")]
public decimal? RatingAverage { get; set; }
[FromQuery(Name = "rating_average_from")]
public decimal? RatingAverageFrom { get; set; }
[FromQuery(Name = "rating_average_to")]
public decimal? RatingAverageTo { get; set; }
[FromQuery(Name = "rating_count")]
public long? RatingCount { get; set; }
[FromQuery(Name = "rating_count_from")]
public long? RatingCountFrom { get; set; }
[FromQuery(Name = "rating_count_to")]
public long? RatingCountTo { get; set; }
[FromQuery(Name = "genre")]
public IEnumerable<short>? Genres { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(MovieResponse item) =>
(
TestStringWithRegex(item.Title, Title)
&&
TestStringWithRegex(item.OriginalTitle, OriginalTitle)
&&
TestStringWithRegex(item.Description, Description)
&&
TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo)
&&
TestComparable(item.Length, Length, LengthFrom, LengthTo)
&&
TestComparable(item.Budget, Budget, BudgetFrom, BudgetTo)
&&
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
&&
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
&&
TestContains(item.Genres.Select(x => x.Id), Genres)
);
#endregion
}

View File

@@ -1,115 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Movies;
public class MovieRatedQueryParameters : QueryParameters<MovieRatedResponse>
{
#region PROPERTIES
[FromQuery(Name = "title")]
public string? Title { get; set; }
[FromQuery(Name = "original_title")]
public string? OriginalTitle { get; set; }
[FromQuery(Name = "description")]
public string? Description { get; set; }
[FromQuery(Name = "release_date")]
public DateOnly? ReleaseDate { get; set; }
[FromQuery(Name = "release_date_from")]
public DateOnly? ReleaseDateFrom { get; set; }
[FromQuery(Name = "release_date_to")]
public DateOnly? ReleaseDateTo { get; set; }
[FromQuery(Name = "length")]
public short? Length { get; set; }
[FromQuery(Name = "length_from")]
public short? LengthFrom { get; set; }
[FromQuery(Name = "length_to")]
public short? LengthTo { get; set; }
[FromQuery(Name = "budget")]
public decimal? Budget { get; set; }
[FromQuery(Name = "budget_from")]
public decimal? BudgetFrom { get; set; }
[FromQuery(Name = "budget_to")]
public decimal? BudgetTo { get; set; }
[FromQuery(Name = "rating_average")]
public decimal? RatingAverage { get; set; }
[FromQuery(Name = "rating_average_from")]
public decimal? RatingAverageFrom { get; set; }
[FromQuery(Name = "rating_average_to")]
public decimal? RatingAverageTo { get; set; }
[FromQuery(Name = "rating_count")]
public long? RatingCount { get; set; }
[FromQuery(Name = "rating_count_from")]
public long? RatingCountFrom { get; set; }
[FromQuery(Name = "rating_count_to")]
public long? RatingCountTo { get; set; }
[FromQuery(Name = "genre")]
public IEnumerable<short>? Genres { get; set; }
[FromQuery(Name = "user_rating")]
public decimal? UserRating { get; set; }
[FromQuery(Name = "user_rating_from")]
public decimal? UserRatingFrom { get; set; }
[FromQuery(Name = "user_rating_to")]
public decimal? UserRatingTo { get; set; }
[FromQuery(Name = "user_rating_date")]
public DateOnly? UserRatingDate { get; set; }
[FromQuery(Name = "user_rating_date_from")]
public DateOnly? UserRatingDateFrom { get; set; }
[FromQuery(Name = "user_rating_date_to")]
public DateOnly? UserRatingDateTo { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(MovieRatedResponse item) =>
(
TestStringWithRegex(item.Title, Title)
&&
TestStringWithRegex(item.OriginalTitle, OriginalTitle)
&&
TestStringWithRegex(item.Description, Description)
&&
TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo)
&&
TestComparable(item.Length, Length, LengthFrom, LengthTo)
&&
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
&&
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
&&
TestContains(Genres, item.Genres.Select(x => x.Id))
&&
TestComparable((decimal)item.UserRating, UserRating, UserRatingFrom, UserRatingTo)
&&
TestComparable(item.UserRatingDate, UserRatingDate, UserRatingDateFrom, UserRatingDateTo)
);
#endregion
}

View File

@@ -1,65 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Model.Genres;
using WatchIt.Common.Model.Rating;
using WatchIt.Common.Query;
using WatchIt.Database.Model.Media;
using WatchIt.Database.Model.Rating;
namespace WatchIt.Common.Model.Movies;
public class MovieRatedResponse : MovieResponse, IQueryOrderable<MovieRatedResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<MovieRatedResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<MovieRatedResponse, IComparable>>
{
{ "id", x => x.Id },
{ "title", x => x.Title },
{ "original_title", x => x.OriginalTitle },
{ "description", x => x.Description },
{ "release_date", x => x.ReleaseDate },
{ "length", x => x.Length },
{ "budget", x => x.Budget },
{ "rating.average", x => x.Rating.Average },
{ "rating.count", x => x.Rating.Count },
{ "user_rating", x => x.UserRating },
{ "user_rating_date", x => x.UserRatingDate }
};
[JsonPropertyName("user_rating")]
public short UserRating { get; set; }
[JsonPropertyName("user_rating_date")]
public DateTime UserRatingDate { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public MovieRatedResponse() { }
[SetsRequiredMembers]
public MovieRatedResponse(MediaMovie mediaMovie, RatingMedia response)
{
Id = mediaMovie.Media.Id;
Title = mediaMovie.Media.Title;
OriginalTitle = mediaMovie.Media.OriginalTitle;
Description = mediaMovie.Media.Description;
ReleaseDate = mediaMovie.Media.ReleaseDate;
Length = mediaMovie.Media.Length;
Budget = mediaMovie.Budget;
Rating = RatingResponseBuilder.Initialize()
.Add(mediaMovie.Media.RatingMedia, x => x.Rating)
.Build();
Genres = mediaMovie.Media.Genres.Select(x => new GenreResponse(x)).ToList();
UserRating = response.Rating;
UserRatingDate = response.Date;
}
#endregion
}

View File

@@ -1,59 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using WatchIt.Database.Model.Media;
namespace WatchIt.Common.Model.Movies;
public class MovieRequest : Movie
{
#region CONSTRUCTORS
[SetsRequiredMembers]
public MovieRequest(MovieResponse initData)
{
Title = initData.Title;
OriginalTitle = initData.OriginalTitle;
Description = initData.Description;
ReleaseDate = initData.ReleaseDate;
Length = initData.Length;
Budget = initData.Budget;
}
public MovieRequest() {}
#endregion
#region PUBLIC METHODS
public Database.Model.Media.Media CreateMedia() => new Database.Model.Media.Media
{
Title = Title,
OriginalTitle = OriginalTitle,
Description = Description,
ReleaseDate = ReleaseDate,
Length = Length,
};
public MediaMovie CreateMediaMovie(long id) => new MediaMovie
{
Id = id,
Budget = Budget,
};
public void UpdateMedia(Database.Model.Media.Media media)
{
media.Title = Title;
media.OriginalTitle = OriginalTitle;
media.Description = Description;
media.ReleaseDate = ReleaseDate;
media.Length = Length;
}
public void UpdateMediaMovie(MediaMovie mediaMovie)
{
mediaMovie.Budget = Budget;
}
#endregion
}

View File

@@ -1,64 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Model.Genres;
using WatchIt.Common.Model.Rating;
using WatchIt.Common.Query;
using WatchIt.Database.Model.Media;
namespace WatchIt.Common.Model.Movies;
public class MovieResponse : Movie, IQueryOrderable<MovieResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<MovieResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<MovieResponse, IComparable>>
{
{ "id", x => x.Id },
{ "title", x => x.Title },
{ "original_title", x => x.OriginalTitle },
{ "description", x => x.Description },
{ "release_date", x => x.ReleaseDate },
{ "length", x => x.Length },
{ "budget", x => x.Budget },
{ "rating.average", x => x.Rating.Average },
{ "rating.count", x => x.Rating.Count }
};
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonPropertyName("rating")]
public RatingResponse Rating { get; set; }
[JsonPropertyName("genres")]
public IEnumerable<GenreResponse> Genres { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public MovieResponse() {}
[SetsRequiredMembers]
public MovieResponse(MediaMovie mediaMovie)
{
Id = mediaMovie.Media.Id;
Title = mediaMovie.Media.Title;
OriginalTitle = mediaMovie.Media.OriginalTitle;
Description = mediaMovie.Media.Description;
ReleaseDate = mediaMovie.Media.ReleaseDate;
Length = mediaMovie.Media.Length;
Budget = mediaMovie.Budget;
Rating = RatingResponseBuilder.Initialize()
.Add(mediaMovie.Media.RatingMedia, x => x.Rating)
.Build();
Genres = mediaMovie.Media.Genres.Select(x => new GenreResponse(x)).ToList();
}
#endregion
}

View File

@@ -1,25 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Persons;
public class Person
{
#region PROPERTIES
[JsonPropertyName("name")]
public required string Name { get; set; }
[JsonPropertyName("full_name")]
public string? FullName { get; set; }
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonPropertyName("birth_date")]
public DateOnly? BirthDate { get; set; }
[JsonPropertyName("death_date")]
public DateOnly? DeathDate { get; set; }
#endregion
}

View File

@@ -1,6 +0,0 @@
namespace WatchIt.Common.Model.Persons;
public class PersonPhoto : Picture
{
}

View File

@@ -1,41 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Person;
namespace WatchIt.Common.Model.Persons;
public class PersonPhotoRequest : PersonPhoto
{
#region CONSTRUCTORS
[JsonConstructor]
public PersonPhotoRequest() {}
[SetsRequiredMembers]
public PersonPhotoRequest(Picture image)
{
Image = image.Image;
MimeType = image.MimeType;
}
#endregion
#region PUBLIC METHODS
public PersonPhotoImage CreatePersonPhotoImage() => new PersonPhotoImage
{
Image = Image,
MimeType = MimeType,
};
public void UpdatePersonPhotoImage(PersonPhotoImage item)
{
item.Image = Image;
item.MimeType = MimeType;
item.UploadDate = DateTime.UtcNow;
}
#endregion
}

View File

@@ -1,36 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Person;
namespace WatchIt.Common.Model.Persons;
public class PersonPhotoResponse : PersonPhoto
{
#region PROPERTIES
[JsonPropertyName("id")]
public Guid Id { get; set; }
[JsonPropertyName("upload_date")]
public DateTime UploadDate { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public PersonPhotoResponse() {}
[SetsRequiredMembers]
public PersonPhotoResponse(PersonPhotoImage personPhotoImage)
{
Id = personPhotoImage.Id;
Image = personPhotoImage.Image;
MimeType = personPhotoImage.MimeType;
UploadDate = personPhotoImage.UploadDate;
}
#endregion
}

View File

@@ -1,84 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Persons;
public class PersonQueryParameters : QueryParameters<PersonResponse>
{
#region PROPERTIES
[FromQuery(Name = "name")]
public string? Name { get; set; }
[FromQuery(Name = "full_name")]
public string? FullName { get; set; }
[FromQuery(Name = "description")]
public string? Description { get; set; }
[FromQuery(Name = "birth_date")]
public DateOnly? BirthDate { get; set; }
[FromQuery(Name = "birth_date_from")]
public DateOnly? BirthDateFrom { get; set; }
[FromQuery(Name = "birth_date_to")]
public DateOnly? BirthDateTo { get; set; }
[FromQuery(Name = "death_date")]
public DateOnly? DeathDate { get; set; }
[FromQuery(Name = "death_date_from")]
public DateOnly? DeathDateFrom { get; set; }
[FromQuery(Name = "death_date_to")]
public DateOnly? DeathDateTo { get; set; }
[FromQuery(Name = "gender_id")]
public short? GenderId { get; set; }
[FromQuery(Name = "rating_average")]
public decimal? RatingAverage { get; set; }
[FromQuery(Name = "rating_average_from")]
public decimal? RatingAverageFrom { get; set; }
[FromQuery(Name = "rating_average_to")]
public decimal? RatingAverageTo { get; set; }
[FromQuery(Name = "rating_count")]
public long? RatingCount { get; set; }
[FromQuery(Name = "rating_count_from")]
public long? RatingCountFrom { get; set; }
[FromQuery(Name = "rating_count_to")]
public long? RatingCountTo { get; set; }
#endregion
#region PUBLIC METHODS
protected override bool IsMeetingConditions(PersonResponse item) =>
(
TestStringWithRegex(item.Name, Name)
&&
TestStringWithRegex(item.FullName, FullName)
&&
TestStringWithRegex(item.Description, Description)
&&
TestComparable(item.BirthDate, BirthDate, BirthDateFrom, BirthDateTo)
&&
TestComparable(item.DeathDate, DeathDate, DeathDateFrom, DeathDateTo)
&&
Test(item.Gender?.Id, GenderId)
&&
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
&&
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
);
#endregion
}

View File

@@ -1,117 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Persons;
public class PersonRatedQueryParameters : QueryParameters<PersonRatedResponse>
{
#region PROPERTIES
[FromQuery(Name = "name")]
public string? Name { get; set; }
[FromQuery(Name = "full_name")]
public string? FullName { get; set; }
[FromQuery(Name = "description")]
public string? Description { get; set; }
[FromQuery(Name = "birth_date")]
public DateOnly? BirthDate { get; set; }
[FromQuery(Name = "birth_date_from")]
public DateOnly? BirthDateFrom { get; set; }
[FromQuery(Name = "birth_date_to")]
public DateOnly? BirthDateTo { get; set; }
[FromQuery(Name = "death_date")]
public DateOnly? DeathDate { get; set; }
[FromQuery(Name = "death_date_from")]
public DateOnly? DeathDateFrom { get; set; }
[FromQuery(Name = "death_date_to")]
public DateOnly? DeathDateTo { get; set; }
[FromQuery(Name = "gender_id")]
public short? GenderId { get; set; }
[FromQuery(Name = "rating_average")]
public decimal? RatingAverage { get; set; }
[FromQuery(Name = "rating_average_from")]
public decimal? RatingAverageFrom { get; set; }
[FromQuery(Name = "rating_average_to")]
public decimal? RatingAverageTo { get; set; }
[FromQuery(Name = "rating_count")]
public long? RatingCount { get; set; }
[FromQuery(Name = "rating_count_from")]
public long? RatingCountFrom { get; set; }
[FromQuery(Name = "rating_count_to")]
public long? RatingCountTo { get; set; }
[FromQuery(Name = "user_rating_average")]
public decimal? UserRatingAverage { get; set; }
[FromQuery(Name = "user_rating_average_from")]
public decimal? UserRatingAverageFrom { get; set; }
[FromQuery(Name = "user_rating_average_to")]
public decimal? UserRatingAverageTo { get; set; }
[FromQuery(Name = "user_rating_count")]
public long? UserRatingCount { get; set; }
[FromQuery(Name = "user_rating_count_from")]
public long? UserRatingCountFrom { get; set; }
[FromQuery(Name = "user_rating_count_to")]
public long? UserRatingCountTo { get; set; }
[FromQuery(Name = "user_rating_date")]
public DateOnly? UserRatingLastDate { get; set; }
[FromQuery(Name = "user_rating_date_from")]
public DateOnly? UserRatingLastDateFrom { get; set; }
[FromQuery(Name = "user_rating_date_to")]
public DateOnly? UserRatingLastDateTo { get; set; }
#endregion
#region PUBLIC METHODS
protected override bool IsMeetingConditions(PersonRatedResponse item) =>
(
TestStringWithRegex(item.Name, Name)
&&
TestStringWithRegex(item.FullName, FullName)
&&
TestStringWithRegex(item.Description, Description)
&&
TestComparable(item.BirthDate, BirthDate, BirthDateFrom, BirthDateTo)
&&
TestComparable(item.DeathDate, DeathDate, DeathDateFrom, DeathDateTo)
&&
Test(item.Gender?.Id, GenderId)
&&
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
&&
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
&&
TestComparable(item.UserRating.Average, UserRatingAverage, UserRatingAverageFrom, UserRatingAverageTo)
&&
TestComparable(item.UserRating.Count, UserRatingCount, UserRatingCountFrom, UserRatingCountTo)
&&
TestComparable(item.UserRatingLastDate, UserRatingLastDate, UserRatingLastDateFrom, UserRatingLastDateTo)
);
#endregion
}

View File

@@ -1,70 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Model.Genders;
using WatchIt.Common.Model.Rating;
using WatchIt.Common.Query;
using WatchIt.Database.Model.Rating;
namespace WatchIt.Common.Model.Persons;
public class PersonRatedResponse : PersonResponse, IQueryOrderable<PersonRatedResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<PersonRatedResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<PersonRatedResponse, IComparable>>
{
{ "id", x => x.Id },
{ "name", x => x.Name },
{ "full_name", x => x.FullName },
{ "description", x => x.Description },
{ "birth_date", x => x.BirthDate },
{ "death_date", x => x.BirthDate },
{ "gender", x => x.Gender.Name },
{ "rating.average", x => x.Rating.Average },
{ "rating.count", x => x.Rating.Count },
{ "user_rating.average", x => x.UserRating.Average },
{ "user_rating.count", x => x.UserRating.Count },
{ "user_rating_last_date", x => x.UserRatingLastDate }
};
[JsonPropertyName("user_rating")]
public RatingResponse UserRating { get; set; }
[JsonPropertyName("user_rating_last_date")]
public DateTime UserRatingLastDate { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public PersonRatedResponse() { }
[SetsRequiredMembers]
public PersonRatedResponse(Database.Model.Person.Person person, IEnumerable<RatingPersonActorRole> actorUserRatings, IEnumerable<RatingPersonCreatorRole> creatorUserRatings)
{
Id = person.Id;
Name = person.Name;
FullName = person.FullName;
Description = person.Description;
BirthDate = person.BirthDate;
DeathDate = person.DeathDate;
Gender = person.Gender is not null ? new GenderResponse(person.Gender) : null;
Rating = RatingResponseBuilder.Initialize()
.Add(person.PersonActorRoles.SelectMany(x => x.RatingPersonActorRole), x => x.Rating)
.Add(person.PersonCreatorRoles.SelectMany(x => x.RatingPersonCreatorRole), x => x.Rating)
.Build();
UserRating = RatingResponseBuilder.Initialize()
.Add(actorUserRatings, x => x.Rating)
.Add(creatorUserRatings, x => x.Rating)
.Build();
UserRatingLastDate = actorUserRatings.Select(x => x.Date)
.Union(creatorUserRatings.Select(x => x.Date))
.Max();
}
#endregion
}

View File

@@ -1,63 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Persons;
public class PersonRequest : Person
{
#region PROPERTIES
[JsonPropertyName("gender_id")]
public short? GenderId { get; set; }
#endregion
#region CONSTRUCTORS
[SetsRequiredMembers]
public PersonRequest()
{
Name = string.Empty;
}
[SetsRequiredMembers]
public PersonRequest(PersonResponse person)
{
Name = person.Name;
FullName = person.FullName;
Description = person.Description;
BirthDate = person.BirthDate;
DeathDate = person.DeathDate;
GenderId = person.Gender?.Id;
}
#endregion
#region PUBLIC METHODS
public Database.Model.Person.Person CreatePerson() => new Database.Model.Person.Person
{
Name = Name,
FullName = FullName,
Description = Description,
BirthDate = BirthDate,
DeathDate = DeathDate,
GenderId = GenderId,
};
public void UpdatePerson(Database.Model.Person.Person person)
{
person.Name = Name;
person.FullName = FullName;
person.Description = Description;
person.BirthDate = BirthDate;
person.DeathDate = DeathDate;
person.GenderId = GenderId;
}
#endregion
}

View File

@@ -1,64 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Model.Genders;
using WatchIt.Common.Model.Rating;
using WatchIt.Common.Query;
using WatchIt.Database.Model.Rating;
namespace WatchIt.Common.Model.Persons;
public class PersonResponse : Person, IQueryOrderable<PersonResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<PersonResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<PersonResponse, IComparable>>
{
{ "id", x => x.Id },
{ "name", x => x.Name },
{ "full_name", x => x.FullName },
{ "description", x => x.Description },
{ "birth_date", x => x.BirthDate },
{ "death_date", x => x.BirthDate },
{ "gender", x => x.Gender.Name },
{ "rating.average", x => x.Rating.Average },
{ "rating.count", x => x.Rating.Count }
};
[JsonPropertyName("id")]
public required long Id { get; set; }
[JsonPropertyName("gender")]
public GenderResponse? Gender { get; set; }
[JsonPropertyName("rating")]
public required RatingResponse Rating { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public PersonResponse() { }
[SetsRequiredMembers]
public PersonResponse(Database.Model.Person.Person person)
{
Id = person.Id;
Name = person.Name;
FullName = person.FullName;
Description = person.Description;
BirthDate = person.BirthDate;
DeathDate = person.DeathDate;
Gender = person.Gender is not null ? new GenderResponse(person.Gender) : null;
Rating = RatingResponseBuilder.Initialize()
.Add(person.PersonActorRoles.SelectMany(x => x.RatingPersonActorRole), x => x.Rating)
.Add(person.PersonCreatorRoles.SelectMany(x => x.RatingPersonCreatorRole), x => x.Rating)
.Build();
}
#endregion
}

View File

@@ -1,13 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Photos;
public abstract class Photo : Picture
{
#region PROPERTIES
[JsonPropertyName("background")]
public PhotoBackgroundData? Background { get; set; }
#endregion
}

View File

@@ -1,19 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Photos;
public class PhotoBackgroundData
{
#region PROPERTIES
[JsonPropertyName("is_universal_background")]
public required bool IsUniversalBackground { get; set; }
[JsonPropertyName("first_gradient_color")]
public required byte[] FirstGradientColor { get; set; }
[JsonPropertyName("second_gradient_color")]
public required byte[] SecondGradientColor { get; set; }
#endregion
}

View File

@@ -1,42 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using WatchIt.Database.Model.Media;
namespace WatchIt.Common.Model.Photos;
public class PhotoBackgroundDataRequest : PhotoBackgroundData
{
#region CONSTRUCTORS
public PhotoBackgroundDataRequest() {}
[SetsRequiredMembers]
public PhotoBackgroundDataRequest(PhotoBackgroundData photoBackgroundData)
{
IsUniversalBackground = photoBackgroundData.IsUniversalBackground;
FirstGradientColor = photoBackgroundData.FirstGradientColor;
SecondGradientColor = photoBackgroundData.SecondGradientColor;
}
#endregion
#region PUBLIC METHODS
public MediaPhotoImageBackground CreateMediaPhotoImageBackground(Guid photoId) => new MediaPhotoImageBackground
{
Id = photoId,
IsUniversalBackground = IsUniversalBackground,
FirstGradientColor = FirstGradientColor,
SecondGradientColor = SecondGradientColor,
};
public void UpdateMediaPhotoImageBackground(MediaPhotoImageBackground image)
{
image.IsUniversalBackground = IsUniversalBackground;
image.FirstGradientColor = FirstGradientColor;
image.SecondGradientColor = SecondGradientColor;
}
#endregion
}

View File

@@ -1,49 +0,0 @@
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Model.Media;
using WatchIt.Common.Model.Series;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Photos;
public class PhotoQueryParameters : QueryParameters<PhotoResponse>
{
#region PROPERTIES
[FromQuery(Name = "mime_type")]
public string? MimeType { get; set; }
[FromQuery(Name = "is_background")]
public bool? IsBackground { get; set; }
[FromQuery(Name = "is_universal_background")]
public bool? IsUniversalBackground { get; set; }
[FromQuery(Name = "upload_date")]
public DateOnly? UploadDate { get; set; }
[FromQuery(Name = "upload_date_from")]
public DateOnly? UploadDateFrom { get; set; }
[FromQuery(Name = "upload_date_to")]
public DateOnly? UploadDateTo { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(PhotoResponse item) =>
(
TestStringWithRegex(item.MimeType, MimeType)
&&
Test(item.Background is not null, IsBackground)
&&
Test(item.Background is not null && item.Background.IsUniversalBackground, IsUniversalBackground)
&&
TestComparable(item.UploadDate, UploadDate, UploadDateFrom, UploadDateTo)
);
#endregion
}

View File

@@ -1,62 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Query;
using WatchIt.Database.Model.Media;
namespace WatchIt.Common.Model.Photos;
public class PhotoResponse : Photo, IQueryOrderable<PhotoResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<PhotoResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<PhotoResponse, IComparable>>
{
{ "id", x => x.Id },
{ "media_id", x => x.MediaId },
{ "mime_type", x => x.MimeType },
{ "is_background", x => x.Background is not null },
{ "is_universal_background", x => x.Background is not null && x.Background.IsUniversalBackground }
};
[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
}

View File

@@ -1,24 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model;
public class Picture
{
#region PROPERTIES
[JsonPropertyName("image")]
public required byte[] Image { get; set; }
[JsonPropertyName("mime_type")]
public required string MimeType { get; set; }
#endregion
#region PUBLIC METHODS
public override string ToString() => $"data:{MimeType};base64,{Convert.ToBase64String(Image)}";
#endregion
}

View File

@@ -1,26 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Rating;
public class RatingRequest
{
#region PROPERTIES
[JsonPropertyName("rating")]
public required short Rating { get; set; }
#endregion
#region CONSTRUCTORS
[SetsRequiredMembers]
public RatingRequest(short rating)
{
Rating = rating;
}
#endregion
}

View File

@@ -1,35 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Person;
using WatchIt.Database.Model.Rating;
namespace WatchIt.Common.Model.Rating;
public class RatingResponse
{
#region PROPERTIES
[JsonPropertyName("average")]
public required decimal Average { get; set; }
[JsonPropertyName("count")]
public required long Count { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public RatingResponse() {}
[SetsRequiredMembers]
internal RatingResponse(long ratingSum, long ratingCount)
{
Average = ratingCount > 0 ? (decimal)ratingSum / ratingCount : 0;
Count = ratingCount;
}
#endregion
}

View File

@@ -1,35 +0,0 @@
namespace WatchIt.Common.Model.Rating;
public class RatingResponseBuilder
{
#region FIELDS
private long _sum;
private long _count;
#endregion
#region CONSTRUCTORS
private RatingResponseBuilder() { }
public static RatingResponseBuilder Initialize() => new RatingResponseBuilder();
#endregion
#region PUBLIC METHODS
public RatingResponseBuilder Add<T>(IEnumerable<T> collection, Func<T, short> selector)
{
_sum += collection.Sum(x => selector(x));
_count += collection.Count();
return this;
}
public RatingResponse Build() => new RatingResponse(_sum, _count);
#endregion
}

View File

@@ -1,16 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Roles;
public abstract class ActorRole
{
#region PROPERTIES
[JsonPropertyName("type_id")]
public short TypeId { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
#endregion
}

View File

@@ -1,26 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace WatchIt.Common.Model.Roles;
public class ActorRoleMediaQueryParameters : ActorRoleQueryParameters
{
#region PROPERTIES
[FromQuery(Name = "person_id")]
public long? PersonId { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(ActorRoleResponse item) =>
(
base.IsMeetingConditions(item)
&&
Test(item.PersonId, PersonId)
);
#endregion
}

View File

@@ -1,22 +0,0 @@
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Person;
namespace WatchIt.Common.Model.Roles;
public class ActorRoleMediaRequest : ActorRoleRequest, IActorRoleMediaRequest
{
#region PROPERTIES
[JsonPropertyName("person_id")]
public long PersonId { get; set; }
#endregion
#region PUBLIC METHODS
public PersonActorRole CreateActorRole(long mediaId) => base.CreateActorRole(mediaId, PersonId);
#endregion
}

View File

@@ -1,26 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace WatchIt.Common.Model.Roles;
public class ActorRolePersonQueryParameters : ActorRoleQueryParameters
{
#region PROPERTIES
[FromQuery(Name = "media_id")]
public long? MediaId { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(ActorRoleResponse item) =>
(
base.IsMeetingConditions(item)
&&
Test(item.MediaId, MediaId)
);
#endregion
}

View File

@@ -1,22 +0,0 @@
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Person;
namespace WatchIt.Common.Model.Roles;
public class ActorRolePersonRequest : ActorRoleRequest, IActorRolePersonRequest
{
#region PROPERTIES
[JsonPropertyName("media_id")]
public long MediaId { get; set; }
#endregion
#region PUBLIC METHODS
public PersonActorRole CreateActorRole(long personId) => base.CreateActorRole(MediaId, personId);
#endregion
}

View File

@@ -1,32 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Roles;
public abstract class ActorRoleQueryParameters : QueryParameters<ActorRoleResponse>
{
#region PROPERTIES
[FromQuery(Name = "type_id")]
public short? TypeId { get; set; }
[FromQuery(Name = "name")]
public string? Name { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(ActorRoleResponse item) =>
(
Test(item.TypeId, TypeId)
&&
TestStringWithRegex(item.Name, Name)
);
#endregion
}

View File

@@ -1,27 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using WatchIt.Database.Model.Person;
namespace WatchIt.Common.Model.Roles;
public abstract class ActorRoleRequest : ActorRole, IActorRoleRequest
{
#region PUBLIC METHODS
public PersonActorRole CreateActorRole(long mediaId, long personId) => new PersonActorRole
{
MediaId = mediaId,
PersonId = personId,
PersonActorRoleTypeId = TypeId,
RoleName = Name,
};
public void UpdateActorRole(PersonActorRole item, long mediaId, long personId)
{
item.MediaId = mediaId;
item.PersonId = personId;
item.PersonActorRoleTypeId = TypeId;
item.RoleName = Name;
}
#endregion
}

View File

@@ -1,48 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Roles;
public class ActorRoleResponse : ActorRole, IQueryOrderable<ActorRoleResponse>, IRoleResponse
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<ActorRoleResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<ActorRoleResponse, IComparable>>
{
{ "name", item => item.Name },
{ "type_id", item => item.TypeId },
};
[JsonPropertyName("id")]
public required Guid Id { get; set; }
[JsonPropertyName("media_id")]
public long MediaId { get; set; }
[JsonPropertyName("person_id")]
public long PersonId { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public ActorRoleResponse() {}
[SetsRequiredMembers]
public ActorRoleResponse(Database.Model.Person.PersonActorRole data)
{
Id = data.Id;
MediaId = data.MediaId;
PersonId = data.PersonId;
TypeId = data.PersonActorRoleTypeId;
Name = data.RoleName;
}
#endregion
}

View File

@@ -1,43 +0,0 @@
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Person;
namespace WatchIt.Common.Model.Roles;
public class ActorRoleUniversalRequest : ActorRoleRequest, IActorRolePersonRequest, IActorRoleMediaRequest
{
#region PROPERTIES
[JsonPropertyName("person_id")]
public long PersonId { get; set; }
[JsonPropertyName("media_id")]
public long MediaId { get; set; }
#endregion
#region CONSTRUCTORS
public ActorRoleUniversalRequest() { }
public ActorRoleUniversalRequest(ActorRoleResponse data)
{
MediaId = data.MediaId;
PersonId = data.PersonId;
TypeId = data.TypeId;
Name = data.Name;
}
#endregion
#region PUBLIC METHODS
public PersonActorRole CreateActorRole() => base.CreateActorRole(MediaId, PersonId);
public void UpdateActorRole(PersonActorRole item) => base.UpdateActorRole(item, MediaId, PersonId);
#endregion
}

View File

@@ -1,13 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Roles;
public abstract class CreatorRole
{
#region PROPERTIES
[JsonPropertyName("type_id")]
public short TypeId { get; set; }
#endregion
}

View File

@@ -1,26 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace WatchIt.Common.Model.Roles;
public class CreatorRoleMediaQueryParameters : CreatorRoleQueryParameters
{
#region PROPERTIES
[FromQuery(Name = "person_id")]
public long? PersonId { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(CreatorRoleResponse item) =>
(
base.IsMeetingConditions(item)
&&
Test(item.PersonId, PersonId)
);
#endregion
}

View File

@@ -1,22 +0,0 @@
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Person;
namespace WatchIt.Common.Model.Roles;
public class CreatorRoleMediaRequest : CreatorRoleRequest, ICreatorRoleMediaRequest
{
#region PROPERTIES
[JsonPropertyName("person_id")]
public long PersonId { get; set; }
#endregion
#region PUBLIC METHODS
public PersonCreatorRole CreateCreatorRole(long mediaId) => base.CreateCreatorRole(mediaId, PersonId);
#endregion
}

View File

@@ -1,26 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace WatchIt.Common.Model.Roles;
public class CreatorRolePersonQueryParameters : CreatorRoleQueryParameters
{
#region PROPERTIES
[FromQuery(Name = "media_id")]
public long? MediaId { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(CreatorRoleResponse item) =>
(
base.IsMeetingConditions(item)
&&
Test(item.MediaId, MediaId)
);
#endregion
}

View File

@@ -1,22 +0,0 @@
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Person;
namespace WatchIt.Common.Model.Roles;
public class CreatorRolePersonRequest : CreatorRoleRequest, ICreatorRolePersonRequest
{
#region PROPERTIES
[JsonPropertyName("media_id")]
public long MediaId { get; set; }
#endregion
#region PUBLIC METHODS
public PersonCreatorRole CreateCreatorRole(long personId) => base.CreateCreatorRole(MediaId, personId);
#endregion
}

View File

@@ -1,25 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Roles;
public abstract class CreatorRoleQueryParameters : QueryParameters<CreatorRoleResponse>
{
#region PROPERTIES
[FromQuery(Name = "type_id")]
public short? TypeId { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(CreatorRoleResponse item) =>
(
Test(item.TypeId, TypeId)
);
#endregion
}

View File

@@ -1,24 +0,0 @@
using WatchIt.Database.Model.Person;
namespace WatchIt.Common.Model.Roles;
public abstract class CreatorRoleRequest : CreatorRole, ICreatorRoleRequest
{
#region PUBLIC METHODS
public PersonCreatorRole CreateCreatorRole(long mediaId, long personId) => new PersonCreatorRole
{
MediaId = mediaId,
PersonId = personId,
PersonCreatorRoleTypeId = TypeId,
};
public void UpdateCreatorRole(PersonCreatorRole item, long mediaId, long personId)
{
item.MediaId = mediaId;
item.PersonId = personId;
item.PersonCreatorRoleTypeId = TypeId;
}
#endregion
}

View File

@@ -1,46 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Roles;
public class CreatorRoleResponse : CreatorRole, IQueryOrderable<CreatorRoleResponse>, IRoleResponse
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<CreatorRoleResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<CreatorRoleResponse, IComparable>>
{
{ "type_id", item => item.TypeId },
};
[JsonPropertyName("id")]
public required Guid Id { get; set; }
[JsonPropertyName("media_id")]
public long MediaId { get; set; }
[JsonPropertyName("person_id")]
public long PersonId { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public CreatorRoleResponse() {}
[SetsRequiredMembers]
public CreatorRoleResponse(Database.Model.Person.PersonCreatorRole data)
{
Id = data.Id;
MediaId = data.MediaId;
PersonId = data.PersonId;
TypeId = data.PersonCreatorRoleTypeId;
}
#endregion
}

View File

@@ -1,42 +0,0 @@
using System.Text.Json.Serialization;
using WatchIt.Database.Model.Person;
namespace WatchIt.Common.Model.Roles;
public class CreatorRoleUniversalRequest : CreatorRoleRequest, ICreatorRolePersonRequest, ICreatorRoleMediaRequest
{
#region PROPERTIES
[JsonPropertyName("person_id")]
public long PersonId { get; set; }
[JsonPropertyName("media_id")]
public long MediaId { get; set; }
#endregion
#region CONSTRUCTORS
public CreatorRoleUniversalRequest() { }
public CreatorRoleUniversalRequest(CreatorRoleResponse data)
{
MediaId = data.MediaId;
PersonId = data.PersonId;
TypeId = data.TypeId;
}
#endregion
#region PUBLIC METHODS
public PersonCreatorRole CreateCreatorRole() => base.CreateCreatorRole(MediaId, PersonId);
public void UpdateCreatorRole(PersonCreatorRole item) => base.UpdateCreatorRole(item, MediaId, PersonId);
#endregion
}

View File

@@ -1,10 +0,0 @@
namespace WatchIt.Common.Model.Roles;
public interface IActorRoleMediaRequest : IActorRoleRequest
{
#region PROPERTIES
public long PersonId { get; set; }
#endregion
}

View File

@@ -1,10 +0,0 @@
namespace WatchIt.Common.Model.Roles;
public interface IActorRolePersonRequest : IActorRoleRequest
{
#region PROPERTIES
public long MediaId { get; set; }
#endregion
}

View File

@@ -1,12 +0,0 @@
namespace WatchIt.Common.Model.Roles;
public interface IActorRoleRequest
{
#region PROPERTIES
public short TypeId { get; set; }
public string Name { get; set; }
#endregion
}

View File

@@ -1,10 +0,0 @@
namespace WatchIt.Common.Model.Roles;
public interface ICreatorRoleMediaRequest : ICreatorRoleRequest
{
#region PROPERTIES
public long PersonId { get; set; }
#endregion
}

View File

@@ -1,10 +0,0 @@
namespace WatchIt.Common.Model.Roles;
public interface ICreatorRolePersonRequest : ICreatorRoleRequest
{
#region PROPERTIES
public long MediaId { get; set; }
#endregion
}

View File

@@ -1,10 +0,0 @@
namespace WatchIt.Common.Model.Roles;
public interface ICreatorRoleRequest
{
#region PROPERTIES
public short TypeId { get; set; }
#endregion
}

View File

@@ -1,9 +0,0 @@
namespace WatchIt.Common.Model.Roles;
public interface IRoleResponse
{
Guid Id { get; set; }
long MediaId { get; set; }
long PersonId { get; set; }
short TypeId { get; set; }
}

View File

@@ -1,13 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Roles;
public class RoleType
{
#region PROPERTIES
[JsonPropertyName("name")]
public required string Name { get; set; }
#endregion
}

View File

@@ -1,22 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Roles;
public class RoleTypeQueryParameters : QueryParameters<RoleTypeResponse>
{
#region PROPERTIES
[FromQuery(Name = "name")]
public string? Name { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(RoleTypeResponse item) => TestStringWithRegex(item.Name, Name);
#endregion
}

View File

@@ -1,18 +0,0 @@
namespace WatchIt.Common.Model.Roles;
public class RoleTypeRequest : RoleType
{
#region PUBLIC METHODS
public Database.Model.Person.PersonActorRoleType CreateActorRoleType() => new Database.Model.Person.PersonActorRoleType()
{
Name = Name
};
public Database.Model.Person.PersonCreatorRoleType CreateCreatorRoleType() => new Database.Model.Person.PersonCreatorRoleType()
{
Name = Name
};
#endregion
}

View File

@@ -1,45 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Roles;
public class RoleTypeResponse : RoleType, IQueryOrderable<RoleTypeResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<RoleTypeResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<RoleTypeResponse, IComparable>>
{
{ "name", item => item.Name }
};
[JsonPropertyName("id")]
public required short Id { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public RoleTypeResponse() { }
[SetsRequiredMembers]
public RoleTypeResponse(Database.Model.Person.PersonCreatorRoleType creatorRoleType)
{
Id = creatorRoleType.Id;
Name = creatorRoleType.Name;
}
[SetsRequiredMembers]
public RoleTypeResponse(Database.Model.Person.PersonActorRoleType actorRoleType)
{
Id = actorRoleType.Id;
Name = actorRoleType.Name;
}
#endregion
}

View File

@@ -1,9 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Model.Series;
public class Series : Media.Media
{
[JsonPropertyName("has_ended")]
public bool HasEnded { get; set; }
}

View File

@@ -1,89 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Series;
public class SeriesQueryParameters : QueryParameters<SeriesResponse>
{
#region PROPERTIES
[FromQuery(Name = "title")]
public string? Title { get; set; }
[FromQuery(Name = "original_title")]
public string? OriginalTitle { get; set; }
[FromQuery(Name = "description")]
public string? Description { get; set; }
[FromQuery(Name = "release_date")]
public DateOnly? ReleaseDate { get; set; }
[FromQuery(Name = "release_date_from")]
public DateOnly? ReleaseDateFrom { get; set; }
[FromQuery(Name = "release_date_to")]
public DateOnly? ReleaseDateTo { get; set; }
[FromQuery(Name = "length")]
public short? Length { get; set; }
[FromQuery(Name = "length_from")]
public short? LengthFrom { get; set; }
[FromQuery(Name = "length_to")]
public short? LengthTo { get; set; }
[FromQuery(Name = "has_ended")]
public bool? HasEnded { get; set; }
[FromQuery(Name = "rating_average")]
public decimal? RatingAverage { get; set; }
[FromQuery(Name = "rating_average_from")]
public decimal? RatingAverageFrom { get; set; }
[FromQuery(Name = "rating_average_to")]
public decimal? RatingAverageTo { get; set; }
[FromQuery(Name = "rating_count")]
public long? RatingCount { get; set; }
[FromQuery(Name = "rating_count_from")]
public long? RatingCountFrom { get; set; }
[FromQuery(Name = "rating_count_to")]
public long? RatingCountTo { get; set; }
[FromQuery(Name = "genre")]
public IEnumerable<short>? Genres { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(SeriesResponse item) =>
(
TestStringWithRegex(item.Title, Title)
&&
TestStringWithRegex(item.OriginalTitle, OriginalTitle)
&&
TestStringWithRegex(item.Description, Description)
&&
TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo)
&&
TestComparable(item.Length, Length, LengthFrom, LengthTo)
&&
Test(item.HasEnded, HasEnded)
&&
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
&&
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
&&
TestContains(item.Genres.Select(x => x.Id), Genres)
);
#endregion
}

View File

@@ -1,111 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Series;
public class SeriesRatedQueryParameters : QueryParameters<SeriesRatedResponse>
{
#region PROPERTIES
[FromQuery(Name = "title")]
public string? Title { get; set; }
[FromQuery(Name = "original_title")]
public string? OriginalTitle { get; set; }
[FromQuery(Name = "description")]
public string? Description { get; set; }
[FromQuery(Name = "release_date")]
public DateOnly? ReleaseDate { get; set; }
[FromQuery(Name = "release_date_from")]
public DateOnly? ReleaseDateFrom { get; set; }
[FromQuery(Name = "release_date_to")]
public DateOnly? ReleaseDateTo { get; set; }
[FromQuery(Name = "length")]
public short? Length { get; set; }
[FromQuery(Name = "length_from")]
public short? LengthFrom { get; set; }
[FromQuery(Name = "length_to")]
public short? LengthTo { get; set; }
[FromQuery(Name = "has_ended")]
public bool? HasEnded { get; set; }
[FromQuery(Name = "rating_average")]
public decimal? RatingAverage { get; set; }
[FromQuery(Name = "rating_average_from")]
public decimal? RatingAverageFrom { get; set; }
[FromQuery(Name = "rating_average_to")]
public decimal? RatingAverageTo { get; set; }
[FromQuery(Name = "rating_count")]
public long? RatingCount { get; set; }
[FromQuery(Name = "rating_count_from")]
public long? RatingCountFrom { get; set; }
[FromQuery(Name = "rating_count_to")]
public long? RatingCountTo { get; set; }
[FromQuery(Name = "genre")]
public IEnumerable<short>? Genres { get; set; }
[FromQuery(Name = "user_rating")]
public decimal? UserRating { get; set; }
[FromQuery(Name = "user_rating_from")]
public decimal? UserRatingFrom { get; set; }
[FromQuery(Name = "user_rating_to")]
public decimal? UserRatingTo { get; set; }
[FromQuery(Name = "user_rating_date")]
public DateOnly? UserRatingDate { get; set; }
[FromQuery(Name = "user_rating_date_from")]
public DateOnly? UserRatingDateFrom { get; set; }
[FromQuery(Name = "user_rating_date_to")]
public DateOnly? UserRatingDateTo { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(SeriesRatedResponse item) =>
(
TestStringWithRegex(item.Title, Title)
&&
TestStringWithRegex(item.OriginalTitle, OriginalTitle)
&&
TestStringWithRegex(item.Description, Description)
&&
TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo)
&&
TestComparable(item.Length, Length, LengthFrom, LengthTo)
&&
Test(item.HasEnded, HasEnded)
&&
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
&&
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
&&
TestContains(item.Genres.Select(x => x.Id), Genres)
&&
TestComparable((decimal)item.UserRating, UserRating, UserRatingFrom, UserRatingTo)
&&
TestComparable(item.UserRatingDate, UserRatingDate, UserRatingDateFrom, UserRatingDateTo)
);
#endregion
}

View File

@@ -1,65 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Model.Genres;
using WatchIt.Common.Model.Rating;
using WatchIt.Common.Query;
using WatchIt.Database.Model.Media;
using WatchIt.Database.Model.Rating;
namespace WatchIt.Common.Model.Series;
public class SeriesRatedResponse : SeriesResponse, IQueryOrderable<SeriesRatedResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<SeriesRatedResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<SeriesRatedResponse, IComparable>>
{
{ "id", x => x.Id },
{ "title", x => x.Title },
{ "original_title", x => x.OriginalTitle },
{ "description", x => x.Description },
{ "release_date", x => x.ReleaseDate },
{ "length", x => x.Length },
{ "has_ended", x => x.HasEnded },
{ "rating.average", x => x.Rating.Average },
{ "rating.count", x => x.Rating.Count },
{ "user_rating", x => x.UserRating },
{ "user_rating_date", x => x.UserRatingDate }
};
[JsonPropertyName("user_rating")]
public short UserRating { get; set; }
[JsonPropertyName("user_rating_date")]
public DateTime UserRatingDate { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public SeriesRatedResponse() { }
[SetsRequiredMembers]
public SeriesRatedResponse(MediaSeries mediaSeries, RatingMedia response)
{
Id = mediaSeries.Media.Id;
Title = mediaSeries.Media.Title;
OriginalTitle = mediaSeries.Media.OriginalTitle;
Description = mediaSeries.Media.Description;
ReleaseDate = mediaSeries.Media.ReleaseDate;
Length = mediaSeries.Media.Length;
HasEnded = mediaSeries.HasEnded;
Rating = RatingResponseBuilder.Initialize()
.Add(mediaSeries.Media.RatingMedia, x => x.Rating)
.Build();
Genres = mediaSeries.Media.Genres.Select(x => new GenreResponse(x)).ToList();
UserRating = response.Rating;
UserRatingDate = response.Date;
}
#endregion
}

View File

@@ -1,59 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using WatchIt.Database.Model.Media;
namespace WatchIt.Common.Model.Series;
public class SeriesRequest : Series
{
#region CONSTRUCTORS
[SetsRequiredMembers]
public SeriesRequest(SeriesResponse initData)
{
Title = initData.Title;
OriginalTitle = initData.OriginalTitle;
Description = initData.Description;
ReleaseDate = initData.ReleaseDate;
Length = initData.Length;
HasEnded = initData.HasEnded;
}
public SeriesRequest() {}
#endregion
#region PUBLIC METHODS
public Database.Model.Media.Media CreateMedia() => new Database.Model.Media.Media
{
Title = Title,
OriginalTitle = OriginalTitle,
Description = Description,
ReleaseDate = ReleaseDate,
Length = Length,
};
public MediaSeries CreateMediaSeries(long id) => new MediaSeries
{
Id = id,
HasEnded = HasEnded,
};
public void UpdateMedia(Database.Model.Media.Media media)
{
media.Title = Title;
media.OriginalTitle = OriginalTitle;
media.Description = Description;
media.ReleaseDate = ReleaseDate;
media.Length = Length;
}
public void UpdateMediaSeries(MediaSeries mediaSeries)
{
mediaSeries.HasEnded = HasEnded;
}
#endregion
}

View File

@@ -1,64 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Model.Genres;
using WatchIt.Common.Model.Rating;
using WatchIt.Common.Query;
using WatchIt.Database.Model.Media;
namespace WatchIt.Common.Model.Series;
public class SeriesResponse : Series, IQueryOrderable<SeriesResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<SeriesResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<SeriesResponse, IComparable>>
{
{ "id", x => x.Id },
{ "title", x => x.Title },
{ "original_title", x => x.OriginalTitle },
{ "description", x => x.Description },
{ "release_date", x => x.ReleaseDate },
{ "length", x => x.Length },
{ "has_ended", x => x.HasEnded },
{ "rating.average", x => x.Rating.Average },
{ "rating.count", x => x.Rating.Count }
};
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonPropertyName("rating")]
public RatingResponse Rating { get; set; }
[JsonPropertyName("genres")]
public IEnumerable<GenreResponse> Genres { get; set; }
#endregion
#region CONSTRUCTORS
[JsonConstructor]
public SeriesResponse() {}
[SetsRequiredMembers]
public SeriesResponse(MediaSeries mediaSeries)
{
Id = mediaSeries.Media.Id;
Title = mediaSeries.Media.Title;
OriginalTitle = mediaSeries.Media.OriginalTitle;
Description = mediaSeries.Media.Description;
ReleaseDate = mediaSeries.Media.ReleaseDate;
Length = mediaSeries.Media.Length;
HasEnded = mediaSeries.HasEnded;
Rating = RatingResponseBuilder.Initialize()
.Add(mediaSeries.Media.RatingMedia, x => x.Rating)
.Build();
Genres = mediaSeries.Media.Genres.Select(x => new GenreResponse(x)).ToList();
}
#endregion
}

View File

@@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\WatchIt.Database\WatchIt.Database.Model\WatchIt.Database.Model\WatchIt.Database.Model.csproj" />
<ProjectReference Include="..\WatchIt.Common.Query\WatchIt.Common.Query.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
</Project>

View File

@@ -1,9 +0,0 @@
using System.Text.Json.Serialization;
namespace WatchIt.Common.Query;
public interface IQueryOrderable<T>
{
[JsonIgnore]
public static abstract IDictionary<string, Func<T, IComparable>> OrderableProperties { get; }
}

View File

@@ -1,175 +0,0 @@
using System.Collections;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Mvc;
namespace WatchIt.Common.Query;
public abstract class QueryParameters
{
#region PROPERTIES
[FromQuery(Name = "order_by")]
public string? OrderBy { get; set; }
[FromQuery(Name = "order")]
public string? Order { get; set; }
[FromQuery(Name = "first")]
public int? First { get; set; }
[FromQuery(Name = "after")]
public int? After { get; set; }
#endregion
#region PUBLIC METHODS
public override string ToString()
{
List<string> queries = new List<string>();
PropertyInfo[] properties = this.GetType().GetProperties();
foreach (PropertyInfo property in properties)
{
object? value = property.GetValue(this);
FromQueryAttribute? attribute = property.GetCustomAttributes<FromQueryAttribute>(true).FirstOrDefault();
if (value is not null && attribute is not null)
{
if (value is IEnumerable enumerable and not string)
{
IEnumerable<string> arrayQueryElements = enumerable.Cast<object>().Select(x => QueryElementToString(attribute.Name!, x.ToString()));
queries.AddRange(arrayQueryElements);
}
else
{
string query = QueryElementToString(attribute.Name!, value);
queries.Add(query);
}
}
}
return $"?{string.Join('&', queries)}";
}
#endregion
#region PRIVATE METHODS
private string QueryElementToString(string name, object value)
{
string valueString = (value switch
{
decimal d => d.ToString(CultureInfo.InvariantCulture),
_ => value.ToString()
})!;
string query = $"{name}={valueString}";
return query;
}
protected static bool Test<T>(T? property, T? query) =>
(
query is null
||
(
property is not null
&&
property.Equals(query)
)
);
protected static bool TestStringWithRegex(string? property, string? regexQuery) =>
(
string.IsNullOrEmpty(regexQuery)
||
(
!string.IsNullOrEmpty(property)
&&
Regex.IsMatch(property, regexQuery, RegexOptions.IgnoreCase)
)
);
protected static bool TestComparable(IComparable? property, IComparable? exact, IComparable? from, IComparable? to) =>
(
(
exact is null
||
(
property is not null
&&
property.CompareTo(exact) == 0
)
)
&&
(
from is null
||
(
property is not null
&&
property.CompareTo(from) >= 0
)
)
&&
(
to is null
||
(
property is not null
&&
property.CompareTo(to) < 0
)
)
);
protected static bool TestContains<T>(IEnumerable<T>? shouldBeInCollection, IEnumerable<T>? collection) =>
(
collection is null
||
shouldBeInCollection is null
||
shouldBeInCollection.All(collection.Contains)
);
#endregion
}
public abstract class QueryParameters<T> : QueryParameters where T : IQueryOrderable<T>
{
#region PUBLIC METHODS
protected abstract bool IsMeetingConditions(T item);
public IEnumerable<T> PrepareData(IEnumerable<T> data)
{
data = data.Where(IsMeetingConditions);
if (OrderBy is not null)
{
if (T.OrderableProperties.TryGetValue(OrderBy, out Func<T, IComparable>? orderFunc))
{
data = Order == "asc" ? data.OrderBy(orderFunc) : data.OrderByDescending(orderFunc);
}
}
if (After is not null)
{
data = data.Skip(After.Value);
}
if (First is not null)
{
data = data.Take(First.Value);
}
return data;
}
#endregion
}

View File

@@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
</Project>

Some files were not shown because too many files have changed in this diff Show More