diff --git a/Modules.Library.Application/Commands/Anime/Episode/Properties/SetDurationCommand.cs b/Modules.Library.Application/Commands/Anime/Episode/Properties/SetDurationCommand.cs new file mode 100644 index 0000000..e69de29 diff --git a/Modules.Library.Application/Commands/Anime/Title/UnrateTitleCommand.cs b/Modules.Library.Application/Commands/Anime/Title/UnvoteTitleCommand.cs similarity index 100% rename from Modules.Library.Application/Commands/Anime/Title/UnrateTitleCommand.cs rename to Modules.Library.Application/Commands/Anime/Title/UnvoteTitleCommand.cs diff --git a/Modules.Library.Application/Commands/Anime/Title/RateTitleCommand.cs b/Modules.Library.Application/Commands/Anime/Title/VoteTitleCommand.cs similarity index 81% rename from Modules.Library.Application/Commands/Anime/Title/RateTitleCommand.cs rename to Modules.Library.Application/Commands/Anime/Title/VoteTitleCommand.cs index e68b40f..48385ff 100644 --- a/Modules.Library.Application/Commands/Anime/Title/RateTitleCommand.cs +++ b/Modules.Library.Application/Commands/Anime/Title/VoteTitleCommand.cs @@ -11,7 +11,7 @@ public class RateTitleCommand : IRequest public ushort RatePercentage { get; set; } } -public class RateTitleCommandHandler(IAnimeTitleGateway titleGateway, UserContext userContext, IMediator mediator) : IRequestHandler +public class VoteTitleCommandHandler(IAnimeTitleGateway titleGateway, UserContext userContext, IMediator mediator) : IRequestHandler { public async Task Handle(RateTitleCommand request, CancellationToken cancellationToken) { @@ -24,7 +24,7 @@ public class RateTitleCommandHandler(IAnimeTitleGateway titleGateway, UserContex var title = await titleGateway.GetById(request.TitleId); if (title != null && !title.Deleted) { - await mediator.Send(new RateObjectCommand { ObjectId = title.Id, SubjectId = subjectId, RatePercentage = request.RatePercentage }); + await mediator.Send(new VoteForObjectCommand { ObjectId = title.Id, SubjectId = subjectId, RatingPercentage = request.RatePercentage }); } return Unit.Value; } diff --git a/Modules.Library.WebApi/Models/Anime/RateEdit.cs b/Modules.Library.WebApi/Models/Anime/VoteEdit.cs similarity index 100% rename from Modules.Library.WebApi/Models/Anime/RateEdit.cs rename to Modules.Library.WebApi/Models/Anime/VoteEdit.cs diff --git a/Modules.Rating.Api/Commands/RateObjectCommand.cs b/Modules.Rating.Api/Commands/VoteForObjectCommand.cs similarity index 83% rename from Modules.Rating.Api/Commands/RateObjectCommand.cs rename to Modules.Rating.Api/Commands/VoteForObjectCommand.cs index 16bf5d0..c395221 100644 --- a/Modules.Rating.Api/Commands/RateObjectCommand.cs +++ b/Modules.Rating.Api/Commands/VoteForObjectCommand.cs @@ -12,7 +12,7 @@ public class RateObjectCommand : IRequest } -public class RateObjectCommandHandler(RateRepository repository) : IRequestHandler +public class VoteForObjectCommandHandler(RatingRepository repository) : IRequestHandler { public async Task Handle(RateObjectCommand request, CancellationToken cancellationToken) { @@ -26,12 +26,12 @@ public class RateObjectCommandHandler(RateRepository repository) : IRequestHandl if (!await repository.IsRateExists(request.ObjectId, request.SubjectId)) { //await repository.AddAsync(new Rate { Key = key, RatePercentage = request.RatePercentage, }); - await repository.AddAsync(new Rate { ObjectId = request.ObjectId, SubjectId = request.SubjectId, RatePercentage = request.RatePercentage, }); + await repository.AddAsync(new Vote { ObjectId = request.ObjectId, SubjectId = request.SubjectId, RatePercentage = request.RatePercentage, }); } else { //await repository.UpdateAsync(new Rate { Key = key, RatePercentage = request.RatePercentage, }); - await repository.UpdateAsync(new Rate { ObjectId = request.ObjectId, SubjectId = request.SubjectId, RatePercentage = request.RatePercentage, }); + await repository.UpdateAsync(new Vote { ObjectId = request.ObjectId, SubjectId = request.SubjectId, RatePercentage = request.RatePercentage, }); } return Unit.Value; } diff --git a/Modules.Rating.Api/Database/Entities/RateKey.cs b/Modules.Rating.Api/Database/Entities/RateKey.cs deleted file mode 100644 index b7b6939..0000000 --- a/Modules.Rating.Api/Database/Entities/RateKey.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Modules.Rating.Api.Database.Entities; - -public class RateKey -{ - public Guid ObjectId { get; set; } = default!; - public Guid SubjectId { get; set; } = default!; -} \ No newline at end of file diff --git a/Modules.Rating.Api/Database/Entities/Rate.cs b/Modules.Rating.Api/Database/Entities/Vote.cs similarity index 100% rename from Modules.Rating.Api/Database/Entities/Rate.cs rename to Modules.Rating.Api/Database/Entities/Vote.cs diff --git a/Modules.Rating.Api/Models/Rate.cs b/Modules.Rating.Api/Models/Vote.cs similarity index 100% rename from Modules.Rating.Api/Models/Rate.cs rename to Modules.Rating.Api/Models/Vote.cs diff --git a/Modules.Rating.Api/Repositories/RateRepository.cs b/Modules.Rating.Api/Repositories/RatingRepository.cs similarity index 87% rename from Modules.Rating.Api/Repositories/RateRepository.cs rename to Modules.Rating.Api/Repositories/RatingRepository.cs index 98f5e62..0f7fab1 100644 --- a/Modules.Rating.Api/Repositories/RateRepository.cs +++ b/Modules.Rating.Api/Repositories/RatingRepository.cs @@ -8,16 +8,16 @@ namespace Modules.Rating.Api.Repositories; public class RateRepository(RatingDbContext context) { private readonly RatingDbContext _context = context; - public async Task AddAsync(Rate entity) + public async Task AddAsync(Vote entity) { if (await IsRateExists(entity.ObjectId, entity.SubjectId)) throw new Exception("Object is already rated by subject"); - _context.Rates.Add(entity); + _context.Votes.Add(entity); await _context.SaveChangesAsync(); } - public async Task UpdateAsync(Rate entity) + public async Task UpdateAsync(Vote entity) { - var rate = await _context.Rates + var rate = await _context.Votes .FirstOrDefaultAsync(q => q.ObjectId == entity.ObjectId && q.SubjectId == entity.SubjectId) ?? throw new Exception("Rate not found"); rate.RatePercentage = entity.RatePercentage; @@ -27,21 +27,21 @@ public class RateRepository(RatingDbContext context) public async Task DeleteAsync(Guid objectId, Guid subjectId) { - var rate = await _context.Rates.FirstOrDefaultAsync(q => q.ObjectId == objectId && q.SubjectId == subjectId); - if (rate != null) _context.Rates?.Remove(rate); + var rate = await _context.Votes.FirstOrDefaultAsync(q => q.ObjectId == objectId && q.SubjectId == subjectId); + if (rate != null) _context.Votes?.Remove(rate); await _context.SaveChangesAsync(); return rate != null; } - public async Task GetFirstOrDefaultWhere(Expression> predicate) => - await _context.Rates.Where(predicate).SingleOrDefaultAsync(); + public async Task GetFirstOrDefaultWhere(Expression> predicate) => + await _context.Votes.Where(predicate).SingleOrDefaultAsync(); - public async Task> GetWhere(Expression> predicate) => - await _context.Rates.Where(predicate).ToListAsync(); + public async Task> GetWhere(Expression> predicate) => + await _context.Votes.Where(predicate).ToListAsync(); internal async Task> GetRates(IEnumerable objectIds, Guid? subjectId) { - var query = _context.Rates.AsQueryable(); + var query = _context.Votes.AsQueryable(); return await query .Where(q => objectIds.Contains(q.ObjectId)) .GroupBy(q => q.ObjectId, (o, r) => new { ObjectId = o, Rate = r.Average(q => q.RatePercentage) }) @@ -137,8 +137,8 @@ public class RateRepository(RatingDbContext context) public async Task GetAverageObjectRate(Guid objectId) { - if (!await _context.Rates.AnyAsync(q => q.ObjectId == objectId)) return null; - return await _context.Rates + if (!await _context.Votes.AnyAsync(q => q.ObjectId == objectId)) return null; + return await _context.Votes .Where(q => q.ObjectId == objectId) .GroupBy(q => q.ObjectId) .Select(q => q.Average(q => q.RatePercentage)) @@ -146,5 +146,5 @@ public class RateRepository(RatingDbContext context) } public async Task IsRateExists(Guid objectId, Guid subjectId) => - await _context.Rates.Where(q => q.ObjectId == objectId && q.SubjectId == subjectId).AnyAsync(); + await _context.Votes.Where(q => q.ObjectId == objectId && q.SubjectId == subjectId).AnyAsync(); } \ No newline at end of file diff --git a/mybookmark.ui/src/components/MediaContent/edit/Anime/AddAnimeSeasonOrEpisodeModalWindowComponent.tsx b/mybookmark.ui/src/components/MediaContent/edit/Anime/AddAnimeSeasonOrEpisodeModalWindowComponent.tsx new file mode 100644 index 0000000..be08bd9 --- /dev/null +++ b/mybookmark.ui/src/components/MediaContent/edit/Anime/AddAnimeSeasonOrEpisodeModalWindowComponent.tsx @@ -0,0 +1,76 @@ +import React, {ReactElement} from "react"; +import ModalWindowComponentBase, {ModalWindowFullscreenMode, ModalWindowSize} from "./ModalWindowComponentBase.tsx"; +import {GetCombinedClassesArray} from "../../../common/Helper.tsx"; + +export interface ITwoButtonModalWindowComponentProps extends React.PropsWithChildren{ + title: string, + first_button_text: string, + first_button_classes: string, + // first_button_small?: boolean | undefined | null, + on_first_button_clicked?: () => void, + + second_button_text: string, + second_button_classes: string, + // second_button_small?: boolean | undefined | null, + on_second_button_clicked?: () => void, + + id? : string | undefined | null, + labelId? : string | undefined | null, + tabIndex? : number | null, + size?: ModalWindowSize | undefined | null, + fullscreen_mode?: ModalWindowFullscreenMode | undefined | null, + fade?: boolean | undefined | null, + vertically_centered?: boolean | undefined | null, + show?: boolean | undefined | null, + onExit?: () => void, + children: ReactElement +} +export default function TwoButtonModalWindowComponent(props: ITwoButtonModalWindowComponentProps){ + const id = props.id != null && props.id != '' ? props.id : Math.random().toString(36).substring(2, 9); + return ( + props.onExit?.()} + > + <> +
+
{props.title}
+ +
+
+ + + + + {props.children} +
+
+ {React.cloneElement(( + + ), + {className: GetCombinedClassesArray(['btn'], props.first_button_classes?.trim() ?? '')})} + + {React.cloneElement(( + + ), + {className: GetCombinedClassesArray(['btn'], props.second_button_classes?.trim() ?? '')})} +
+ +
+ ); +} \ No newline at end of file diff --git a/mybookmark.ui/src/components/common/ModalWindow/ModalWindowComponentBase.tsx b/mybookmark.ui/src/components/common/ModalWindow/ModalWindowComponentBase.tsx new file mode 100644 index 0000000..a14292e --- /dev/null +++ b/mybookmark.ui/src/components/common/ModalWindow/ModalWindowComponentBase.tsx @@ -0,0 +1,8 @@ +import React, {ReactElement} from "react"; + +export interface IModalWindowComponentProps extends React.PropsWithChildren{ + children: ReactElement +} +export default function ModalWindowComponent(props: IModalWindowComponentProps){ + return (props.children); +} \ No newline at end of file diff --git a/mybookmark.ui/src/components/common/ModalWindow/TwoButtonModalWindowComponent.tsx b/mybookmark.ui/src/components/common/ModalWindow/TwoButtonModalWindowComponent.tsx new file mode 100644 index 0000000..e69de29 diff --git a/mybookmark.ui/src/components/common/TimespanComponent.tsx b/mybookmark.ui/src/components/common/TimespanComponent.tsx new file mode 100644 index 0000000..e69de29 diff --git a/mybookmark.ui/src/pages/library/edit/AnimeEpisodeCreate.tsx b/mybookmark.ui/src/pages/library/edit/AnimeEpisodeCreate.tsx new file mode 100644 index 0000000..e69de29 diff --git a/mybookmark.ui/src/pages/library/edit/AnimeSeasonCreate.tsx b/mybookmark.ui/src/pages/library/edit/AnimeSeasonCreate.tsx new file mode 100644 index 0000000..e69de29