diff --git a/src/BukiVedi.App/Controllers/BooksController.cs b/src/BukiVedi.App/Controllers/BooksController.cs
index fbd193b..394e7bc 100644
--- a/src/BukiVedi.App/Controllers/BooksController.cs
+++ b/src/BukiVedi.App/Controllers/BooksController.cs
@@ -37,6 +37,7 @@ namespace BukiVedi.App.Controllers
}
#endregion
+
///
/// Добавление книги в избранное
///
diff --git a/src/BukiVedi.App/Properties/PublishProfiles/FolderProfile.pubxml.user b/src/BukiVedi.App/Properties/PublishProfiles/FolderProfile.pubxml.user
index b6c99dc..00510cb 100644
--- a/src/BukiVedi.App/Properties/PublishProfiles/FolderProfile.pubxml.user
+++ b/src/BukiVedi.App/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<_PublishTargetUrl>G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Release\net8.0\publish\
- True|2024-05-12T17:17:18.3446630Z;True|2024-05-12T20:11:53.1976666+03:00;True|2024-04-28T17:30:08.5715518+03:00;True|2024-04-28T17:28:06.6959908+03:00;True|2024-04-28T16:38:39.9281743+03:00;False|2024-04-28T16:36:56.3567692+03:00;False|2024-04-28T16:36:21.9546945+03:00;False|2024-04-28T16:35:24.2096595+03:00;True|2024-04-09T13:52:12.7238098+03:00;True|2024-04-07T21:16:45.6816851+03:00;True|2024-04-07T05:01:48.6765910+03:00;True|2024-04-07T05:01:36.8953339+03:00;True|2024-04-07T04:57:19.2521218+03:00;True|2024-04-06T21:11:57.8349210+03:00;True|2024-04-06T17:36:58.3428821+03:00;True|2024-04-05T04:52:06.7814045+03:00;True|2024-04-05T04:46:11.3960475+03:00;True|2024-04-04T16:59:14.8807703+03:00;True|2024-04-04T14:55:51.0062074+03:00;True|2024-04-04T14:01:53.0402462+03:00;True|2024-04-04T05:50:10.9326327+03:00;True|2024-04-04T05:23:22.3837261+03:00;True|2024-04-04T05:18:08.8436345+03:00;True|2024-04-04T05:13:03.4261357+03:00;True|2024-04-04T04:23:59.4217155+03:00;True|2024-04-04T04:12:10.2381826+03:00;True|2024-04-04T04:04:27.2386390+03:00;
+ True|2024-05-27T18:54:10.5214496Z;True|2024-05-12T20:17:18.3446630+03:00;True|2024-05-12T20:11:53.1976666+03:00;True|2024-04-28T17:30:08.5715518+03:00;True|2024-04-28T17:28:06.6959908+03:00;True|2024-04-28T16:38:39.9281743+03:00;False|2024-04-28T16:36:56.3567692+03:00;False|2024-04-28T16:36:21.9546945+03:00;False|2024-04-28T16:35:24.2096595+03:00;True|2024-04-09T13:52:12.7238098+03:00;True|2024-04-07T21:16:45.6816851+03:00;True|2024-04-07T05:01:48.6765910+03:00;True|2024-04-07T05:01:36.8953339+03:00;True|2024-04-07T04:57:19.2521218+03:00;True|2024-04-06T21:11:57.8349210+03:00;True|2024-04-06T17:36:58.3428821+03:00;True|2024-04-05T04:52:06.7814045+03:00;True|2024-04-05T04:46:11.3960475+03:00;True|2024-04-04T16:59:14.8807703+03:00;True|2024-04-04T14:55:51.0062074+03:00;True|2024-04-04T14:01:53.0402462+03:00;True|2024-04-04T05:50:10.9326327+03:00;True|2024-04-04T05:23:22.3837261+03:00;True|2024-04-04T05:18:08.8436345+03:00;True|2024-04-04T05:13:03.4261357+03:00;True|2024-04-04T04:23:59.4217155+03:00;True|2024-04-04T04:12:10.2381826+03:00;True|2024-04-04T04:04:27.2386390+03:00;
\ No newline at end of file
diff --git a/src/BukiVedi.App/Services/Mappers/BookEntityMapper.cs b/src/BukiVedi.App/Services/Mappers/BookEntityMapper.cs
deleted file mode 100644
index f4111ec..0000000
--- a/src/BukiVedi.App/Services/Mappers/BookEntityMapper.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using BukiVedi.Shared.Entities;
-using BukiVedi.Shared.Models;
-using BukiVedi.Shared.Services;
-using MongoDB.Driver;
-
-namespace BukiVedi.App.Services.Mappers
-{
- public class BookEntityMapper
- {
- public static async Task> Map(IEnumerable books)
- {
- var booksIds = books.Select(x => x.Id).ToList();
- var tags_list = (await Tables.UserTag.Get(Builders.Filter.In(t => t.BookId, booksIds)));
- var tags = new Dictionary>();
- foreach (var t in tags_list)
- {
- if (tags.TryGetValue(t.BookId, out var list)) { list.Add(new TagInfo { Id = t.Id, Name = t.Name }); }
- else
- {
- tags.Add(t.BookId,
- new List
- {
- new TagInfo { Id = t.Id, Name = t.Name }
- });
- }
- }
-
- return books.Select(book =>
- new BookInfo
- {
- Authors = book.Authors.Select(a => new AuthorInfo { Id = a.Id, Name = a.Name }).ToArray(),
- Description = book.Description,
- Format = book.Format,
- Id = book.Id,
- Genres = new GenreInfo[1] { new GenreInfo { Id = book.Genre.Id, Name = book.Genre.Code } },
- Title = book.Title,
- Year = book.Year,
- Tags = tags.ContainsKey(book.Id) ? tags[book.Id] : null!
- });
- }
- }
-}
diff --git a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.AssemblyInfo.cs b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.AssemblyInfo.cs
index 420cbb4..f142e7a 100644
--- a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.AssemblyInfo.cs
+++ b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.AssemblyInfo.cs
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("BukiVedi.App")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+112daccec93b21f74faf3a3b85b2f9a47b2ae81f")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f836c4963b5e99aa3f8cf1767a7e2475c8365585")]
[assembly: System.Reflection.AssemblyProductAttribute("BukiVedi.App")]
[assembly: System.Reflection.AssemblyTitleAttribute("BukiVedi.App")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.AssemblyInfoInputs.cache b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.AssemblyInfoInputs.cache
index 9de1179..837c232 100644
--- a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.AssemblyInfoInputs.cache
+++ b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.AssemblyInfoInputs.cache
@@ -1 +1 @@
-a7e97588f3d72640975deb9345bc56ed8105e4a411d7365c01f74b565d536185
+4b4b9b8782de19706da19d9f622b1c0ae0f67e76d13507633e9b217526407a05
diff --git a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.AssemblyReference.cache b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.AssemblyReference.cache
index f3218c2..774ca94 100644
Binary files a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.AssemblyReference.cache and b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.AssemblyReference.cache differ
diff --git a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.CoreCompileInputs.cache b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.CoreCompileInputs.cache
index 7b7632b..d034aeb 100644
--- a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.CoreCompileInputs.cache
+++ b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-01863397d052ecaa66378570909483d909afc157f0ec741e43d4b803613bad26
+ed81abf2574a377e553a94f81fb7f13635914d0a568744fd6688eb2402f4589b
diff --git a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.FileListAbsolute.txt b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.FileListAbsolute.txt
index 1908ea3..5e32a39 100644
--- a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.FileListAbsolute.txt
+++ b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.csproj.FileListAbsolute.txt
@@ -80,8 +80,6 @@ G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Debug\net8.0\web\fonts\Roboto-
G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Debug\net8.0\web\fonts\Roboto-Regular.ttf
G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Debug\net8.0\web\fonts\Roboto-Thin.ttf
G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Debug\net8.0\web\fonts\Roboto-ThinItalic.ttf
-G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Debug\net8.0\LemmaSharpPrebuilt.pdb
-G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Debug\net8.0\LemmaSharpPrebuilt.dll.config
G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Debug\net8.0\web\js\common\jquery.js
G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Debug\net8.0\web\js\constants\index.js
G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Debug\net8.0\web\js\login\index.js
diff --git a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.pdb b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.pdb
index 6542b0d..cee6d46 100644
Binary files a/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.pdb and b/src/BukiVedi.App/obj/Debug/net8.0/BukiVedi.App.pdb differ
diff --git a/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.AssemblyInfo.cs b/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.AssemblyInfo.cs
index 2067511..d99719d 100644
--- a/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.AssemblyInfo.cs
+++ b/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.AssemblyInfo.cs
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("BukiVedi.App")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+431f2503a837ccf39eac97076a865db39f86a8dd")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f836c4963b5e99aa3f8cf1767a7e2475c8365585")]
[assembly: System.Reflection.AssemblyProductAttribute("BukiVedi.App")]
[assembly: System.Reflection.AssemblyTitleAttribute("BukiVedi.App")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.AssemblyInfoInputs.cache b/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.AssemblyInfoInputs.cache
index aa72588..1343d33 100644
--- a/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.AssemblyInfoInputs.cache
+++ b/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.AssemblyInfoInputs.cache
@@ -1 +1 @@
-731a41efb4470858e97b70db5c6c673a43866001a9d9b8ac769cdb5c62d8eec0
+29025db0182771bf6cf91cb9d325b9bf6b103812996e3476ba09ddfdcd3dd811
diff --git a/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.csproj.AssemblyReference.cache b/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.csproj.AssemblyReference.cache
index 0cc8d4d..1ab2f16 100644
Binary files a/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.csproj.AssemblyReference.cache and b/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.csproj.AssemblyReference.cache differ
diff --git a/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.csproj.FileListAbsolute.txt b/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.csproj.FileListAbsolute.txt
index 367237f..115a392 100644
--- a/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.csproj.FileListAbsolute.txt
+++ b/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.csproj.FileListAbsolute.txt
@@ -88,3 +88,7 @@ G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Release\net8.0\web\js\main\ind
G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Release\net8.0\web\js\requests\index.js
G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Release\net8.0\web\js\scroll\index.js
G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Release\net8.0\web\script.js
+G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Release\net8.0\web\assets\pencil.svg
+G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Release\net8.0\web\js\common\jquery.min.js
+G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Release\net8.0\web\js\components\tags\index.js
+G:\Documents\GitHub\BukiVedi\src\BukiVedi.App\bin\Release\net8.0\web\js\utils\index.js
diff --git a/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.pdb b/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.pdb
index b3958a1..c02bace 100644
Binary files a/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.pdb and b/src/BukiVedi.App/obj/Release/net8.0/BukiVedi.App.pdb differ
diff --git a/src/BukiVedi.Shared/Apps/AuthorHandler.cs b/src/BukiVedi.Shared/Apps/AuthorHandler.cs
index 72f7ea1..1febf96 100644
--- a/src/BukiVedi.Shared/Apps/AuthorHandler.cs
+++ b/src/BukiVedi.Shared/Apps/AuthorHandler.cs
@@ -2,7 +2,6 @@
using BukiVedi.Shared.Models;
using BukiVedi.Shared.Services;
using BukiVedi.Shared.Services.Mappers;
-using MongoDB.Driver;
namespace BukiVedi.Shared.Apps
{
@@ -18,50 +17,46 @@ namespace BukiVedi.Shared.Apps
public async Task AddToFavorite(string id, OperationContext context)
{
- if (context?.OperationInitiator?.Id == null) throw new InvalidOperationException("Unauthorized");
- var exists_fiter = Builders.Filter.And
- (
- Builders.Filter.Eq(f => f.UserId, context.OperationInitiator.Id),
- Builders.Filter.Eq(f => f.AuthorId, id)
- );
- if (await Tables.FavoriteAuthors.Exists(exists_fiter) == false)
+ if (await Tables.FavoriteAuthors.Exists(Filters.FavoriteAuthors.Exact(id, context.OperationInitiator.Id)) == false)
{
await Tables.FavoriteAuthors.Write(new FavoriteAuthor { AuthorId = id, UserId = context.OperationInitiator.Id });
}
}
- public async Task> GetAllAuthors(OperationContext context)
- {
- var authors = (await Tables.Authors.GetAll()).Select(a => new AuthorInfo { Id = a.Id, Name = a.Name }).ToArray();
- return authors;
- }
+ public async Task> GetAllAuthors(OperationContext context) =>
+ (await Tables.Authors.GetAll()).Select(a => new AuthorInfo { Id = a.Id, Name = a.Name })?.ToArray()!;
public async Task> GetFavoriteAuthors(OperationContext context)
{
- var authorIds = (await Tables.FavoriteAuthors.Get(Builders.Filter.Eq(f => f.UserId, context.OperationInitiator.Id))).Select(f => f.AuthorId).ToHashSet();
- var authors = (await Tables.Authors.Get(Builders.Filter.In(a => a.Id, authorIds))).Select(a => new AuthorInfo { Id = a.Id, Name = a.Name }).ToArray();
- return authors;
+ var authorIds = (await Tables.FavoriteAuthors.Get(Filters.FavoriteAuthors.ByUser(context.OperationInitiator.Id)))?.Select(f => f.AuthorId)?.ToHashSet()!;
+ if (authorIds != null && authorIds.Any())
+ {
+ var authors = (await Tables.Authors.Get(Filters.Authors.ByIds(authorIds)))?.Select(a => new AuthorInfo { Id = a.Id, Name = a.Name })?.ToArray()!;
+ return authors;
+ }
+ return Enumerable.Empty();
}
public async Task RemoveFromFavorite(string id, OperationContext context)
{
- if (context?.OperationInitiator?.Id == null) throw new InvalidOperationException("Unauthorized");
- var exists_fiter = Builders.Filter.And
- (
- Builders.Filter.Eq(f => f.UserId, context.OperationInitiator.Id),
- Builders.Filter.Eq(f => f.AuthorId, id)
- );
- var records = await Tables.FavoriteAuthors.Get(exists_fiter);
- foreach (var record in records)
+ var records = (await Tables.FavoriteAuthors.Get(Filters.FavoriteAuthors.Exact(id, context.OperationInitiator.Id)))?.ToHashSet()!;
+ if (records != null && records.Count > 0)
{
- await Tables.FavoriteAuthors.TryRemoveById(record.Id);
+ foreach (var record in records)
+ {
+ await Tables.FavoriteAuthors.TryRemoveById(record.Id);
+ }
}
}
public async Task> SearchByAuthor(string id, OperationContext context)
{
- var books = (await _library.SearchBooksByAuthor(id)).ToArray();
- return await BookEntityMapper.Map(books);
+ var books = (await _library.SearchBooksByAuthor(id))?.ToArray()!;
+ if (books != null && books.Any())
+ {
+ return await BookEntityMapper.Map(books, context);
+ }
+ return Enumerable.Empty();
}
}
}
diff --git a/src/BukiVedi.Shared/Apps/BooksHandler.cs b/src/BukiVedi.Shared/Apps/BooksHandler.cs
index 9211fe7..bb52744 100644
--- a/src/BukiVedi.Shared/Apps/BooksHandler.cs
+++ b/src/BukiVedi.Shared/Apps/BooksHandler.cs
@@ -1,15 +1,7 @@
-using Amazon.Runtime.Internal;
-using BukiVedi.Shared.Entities;
+using BukiVedi.Shared.Entities;
using BukiVedi.Shared.Models;
using BukiVedi.Shared.Services;
using BukiVedi.Shared.Services.Mappers;
-using MongoDB.Driver;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection.Metadata;
-using System.Text;
-using System.Threading.Tasks;
using ZeroLevel.Services.FileSystem;
namespace BukiVedi.Shared.Apps
@@ -33,16 +25,11 @@ namespace BukiVedi.Shared.Apps
var authors = book.AuthorIds;
if (!string.IsNullOrEmpty(account_id) && authors?.Count > 0)
{
- foreach (var author in authors)
+ foreach (var author_id in authors)
{
- var exists_fiter = Builders.Filter.And
- (
- Builders.Filter.Eq(f => f.UserId, account_id),
- Builders.Filter.Eq(f => f.AuthorId, author)
- );
- if (await Tables.FavoriteAuthors.Exists(exists_fiter) == false)
+ if (await Tables.FavoriteAuthors.Exists(Filters.FavoriteAuthors.Exact(author_id, account_id)) == false)
{
- await Tables.FavoriteAuthors.Write(new FavoriteAuthor { AuthorId = author, UserId = account_id });
+ await Tables.FavoriteAuthors.Write(new FavoriteAuthor { AuthorId = author_id, UserId = account_id });
}
}
}
@@ -56,12 +43,7 @@ namespace BukiVedi.Shared.Apps
var account_id = context.OperationInitiator.Id;
if (!string.IsNullOrEmpty(account_id))
{
- var exists_fiter = Builders.Filter.And
- (
- Builders.Filter.Eq(f => f.UserId, account_id),
- Builders.Filter.Eq(f => f.BookId, id)
- );
- if (await Tables.ReadQueue.Exists(exists_fiter) == false)
+ if (await Tables.ReadQueue.Exists(Filters.BooksToRead.Exact(id, account_id)) == false)
{
await Tables.ReadQueue.Write(new ReadQueueItem { BookId = id, UserId = account_id, Timestamp = Timestamp.UtcNow });
}
@@ -76,12 +58,7 @@ namespace BukiVedi.Shared.Apps
var account_id = context.OperationInitiator.Id;
if (!string.IsNullOrEmpty(account_id))
{
- var exists_fiter = Builders.Filter.And
- (
- Builders.Filter.Eq(f => f.UserId, account_id),
- Builders.Filter.Eq(f => f.BookId, id)
- );
- if (await Tables.FavoriteBooks.Exists(exists_fiter) == false)
+ if (await Tables.FavoriteBooks.Exists(Filters.FavoriteBooks.ByBook(id, account_id)) == false)
{
await Tables.FavoriteBooks.Write(new FavoriteBook { BookId = id, UserId = account_id });
}
@@ -96,12 +73,7 @@ namespace BukiVedi.Shared.Apps
var account_id = context.OperationInitiator.Id;
if (!string.IsNullOrEmpty(account_id))
{
- var exists_fiter = Builders.Filter.And
- (
- Builders.Filter.Eq(f => f.UserId, account_id),
- Builders.Filter.Eq(f => f.BookId, id)
- );
- if (await Tables.DisgustingBooks.Exists(exists_fiter) == false)
+ if (await Tables.DisgustingBooks.Exists(Filters.DisgustingBooks.ByBook(id, account_id)) == false)
{
await Tables.DisgustingBooks.Write(new DisgustingBook { BookId = id, UserId = account_id });
}
@@ -120,12 +92,7 @@ namespace BukiVedi.Shared.Apps
{
foreach (var author in authors)
{
- var exists_fiter = Builders.Filter.And
- (
- Builders.Filter.Eq(f => f.UserId, account_id),
- Builders.Filter.Eq(f => f.AuthorId, author)
- );
- if (await Tables.DisgustingAuthors.Exists(exists_fiter) == false)
+ if (await Tables.DisgustingAuthors.Exists(Filters.DisgustingAuthors.ByAuthor(author, account_id)) == false)
{
await Tables.DisgustingAuthors.Write(new DisgustingAuthor { AuthorId = author, UserId = account_id });
}
@@ -149,13 +116,7 @@ namespace BukiVedi.Shared.Apps
public async Task RemoveFromFavorite(string id, OperationContext context)
{
- if (context?.OperationInitiator?.Id == null) throw new InvalidOperationException("Unauthorized");
- var exists_fiter = Builders.Filter.And
- (
- Builders.Filter.Eq(f => f.UserId, context.OperationInitiator.Id),
- Builders.Filter.Eq(f => f.BookId, id)
- );
- var records = await Tables.FavoriteBooks.Get(exists_fiter);
+ var records = await Tables.FavoriteBooks.Get(Filters.FavoriteBooks.ByBook(id, context.OperationInitiator.Id));
foreach (var record in records)
{
await Tables.FavoriteBooks.TryRemoveById(record.Id);
@@ -164,13 +125,7 @@ namespace BukiVedi.Shared.Apps
public async Task RemoveFromReadingQueue(string id, OperationContext context)
{
- if (context?.OperationInitiator?.Id == null) throw new InvalidOperationException("Unauthorized");
- var exists_fiter = Builders.Filter.And
- (
- Builders.Filter.Eq(f => f.UserId, context.OperationInitiator.Id),
- Builders.Filter.Eq(f => f.BookId, id)
- );
- var records = await Tables.ReadQueue.Get(exists_fiter);
+ var records = await Tables.ReadQueue.Get(Filters.BooksToRead.Exact(id, context.OperationInitiator.Id));
foreach (var record in records)
{
await Tables.ReadQueue.TryRemoveById(record.Id);
@@ -186,35 +141,35 @@ namespace BukiVedi.Shared.Apps
case "@favorites":
{
var books = (await _library.SearchFavoritesBooks(context.OperationInitiator.Id)).ToArray();
- return await BookEntityMapper.Map(books);
+ return await BookEntityMapper.Map(books, context);
}
case "@favoriteauthors":
{
var books = (await _library.SearchFavoriteAuthorsBooks(context.OperationInitiator.Id)).ToArray();
- return await BookEntityMapper.Map(books);
+ return await BookEntityMapper.Map(books, context);
}
case "@tagged":
{
var books = (await _library.SearchTaggedBooks(context.OperationInitiator.Id, tag: tag!)).ToArray();
- return await BookEntityMapper.Map(books);
+ return await BookEntityMapper.Map(books, context);
}
case "@blocked":
{
var books = (await _library.SearchBlockedBooks(context.OperationInitiator.Id)).ToArray();
- return await BookEntityMapper.Map(books);
+ return await BookEntityMapper.Map(books, context);
}
case "@toread":
{
var books = (await _library.SearchToReadBooks(context.OperationInitiator.Id)).ToArray();
- return await BookEntityMapper.Map(books);
+ return await BookEntityMapper.Map(books, context);
}
default:
{
var books = (await _library.SearchBooks(query)).ToArray();
- return await BookEntityMapper.Map(books);
+ return await BookEntityMapper.Map(books, context);
}
}
}
@@ -223,16 +178,10 @@ namespace BukiVedi.Shared.Apps
public async Task UnblockBook(string id, OperationContext context)
{
- if (context?.OperationInitiator?.Id == null) throw new InvalidOperationException("Unauthorized");
var account_id = context.OperationInitiator.Id;
if (!string.IsNullOrEmpty(account_id))
{
- var exists_fiter = Builders.Filter.And
- (
- Builders.Filter.Eq(f => f.UserId, account_id),
- Builders.Filter.Eq(f => f.BookId, id)
- );
- var records = await Tables.DisgustingBooks.Get(exists_fiter);
+ var records = await Tables.DisgustingBooks.Get(Filters.DisgustingBooks.ByBook(id, account_id));
foreach (var record in records)
{
await Tables.DisgustingBooks.TryRemoveById(record.Id);
diff --git a/src/BukiVedi.Shared/Apps/TagsHandler.cs b/src/BukiVedi.Shared/Apps/TagsHandler.cs
index a32e403..9a5a7be 100644
--- a/src/BukiVedi.Shared/Apps/TagsHandler.cs
+++ b/src/BukiVedi.Shared/Apps/TagsHandler.cs
@@ -2,7 +2,6 @@
using BukiVedi.Shared.Models;
using BukiVedi.Shared.Services;
using BukiVedi.Shared.Services.Mappers;
-using MongoDB.Driver;
namespace BukiVedi.Shared.Apps
{
@@ -21,7 +20,7 @@ namespace BukiVedi.Shared.Apps
if (string.IsNullOrWhiteSpace(name) == false && await Tables.Books.ExistById(bookId))
{
name = name.Trim().ToLowerInvariant();
- var tagFilter = Builders.Filter.And(Builders.Filter.And(Builders.Filter.Eq(t => t.BookId, bookId), Builders.Filter.Eq(t => t.Name, name)), Builders.Filter.Eq(t => t.UserId, context.OperationInitiator.Id));
+ var tagFilter = Filters.Tags.Exact(bookId, context.OperationInitiator.Id, name);
var existTag = await Tables.UserTag.Get(tagFilter);
if (existTag != null && existTag.Length > 0)
{
@@ -38,9 +37,7 @@ namespace BukiVedi.Shared.Apps
public async Task> GetBookTags(string bookId, OperationContext context)
{
- var userFilter = Builders.Filter.Eq(t => t.UserId, context.OperationInitiator.Id);
- var bookFilter = Builders.Filter.Eq(t => t.BookId, bookId);
- var filter = Builders.Filter.And(userFilter, bookFilter);
+ var filter = Filters.Tags.ByBook(bookId, context.OperationInitiator.Id);
return (await Tables.UserTag.Get(filter))?.Select(t => new TagInfo
{
Id = t.Id,
@@ -50,7 +47,7 @@ namespace BukiVedi.Shared.Apps
public async Task> GetUserTags(OperationContext context)
{
- return (await Tables.UserTag.Get(Builders.Filter.Eq(t => t.UserId, context.OperationInitiator.Id)))?.Select(t => t.Name)!;
+ return (await Tables.UserTag.Get(Filters.Tags.ByUser(context.OperationInitiator.Id)))?.Select(t => t.Name)!;
}
public async Task RemoveTag(string id, OperationContext context)
@@ -67,7 +64,7 @@ namespace BukiVedi.Shared.Apps
if (string.IsNullOrWhiteSpace(id) == false)
{
var books = await _library.SearchByTagBooks(context.OperationInitiator.Id, id);
- return await BookEntityMapper.Map(books);
+ return await BookEntityMapper.Map(books, context);
}
return Enumerable.Empty();
}
diff --git a/src/BukiVedi.Shared/Services/AuthProvider.cs b/src/BukiVedi.Shared/Services/AuthProvider.cs
index c449fcb..dfa80a4 100644
--- a/src/BukiVedi.Shared/Services/AuthProvider.cs
+++ b/src/BukiVedi.Shared/Services/AuthProvider.cs
@@ -1,5 +1,4 @@
using BukiVedi.Shared.Entities;
-using MongoDB.Driver;
namespace BukiVedi.Shared.Services
{
@@ -21,7 +20,7 @@ namespace BukiVedi.Shared.Services
}
return await _accountRepository.Write(account);
}
- public async Task GetAccountByLogin(string login) => (await _accountRepository.Get(Builders.Filter.Eq(a => a.Login, login))).FirstOrDefault()!;
+ public async Task GetAccountByLogin(string login) => (await _accountRepository.Get(Filters.Auth.ByLogin(login))).FirstOrDefault()!;
public async Task GetAccount(string id) => await _accountRepository.GetById(id);
public async Task GetAccount(string login, string password)
{
diff --git a/src/BukiVedi.Shared/Services/Filters.cs b/src/BukiVedi.Shared/Services/Filters.cs
new file mode 100644
index 0000000..9938bd4
--- /dev/null
+++ b/src/BukiVedi.Shared/Services/Filters.cs
@@ -0,0 +1,278 @@
+using BukiVedi.Shared.Entities;
+using MongoDB.Driver;
+using System.Net;
+
+namespace BukiVedi.Shared.Services
+{
+ ///
+ /// Фабрика фильтров
+ ///
+ public static class Filters
+ {
+ ///
+ /// Теги
+ ///
+ public static class Tags
+ {
+ ///
+ /// По пользователю
+ ///
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByUser(string userId) => Builders.Filter.Eq(t => t.UserId, userId);
+
+ ///
+ /// По названию тега
+ ///
+ /// Название тега
+ /// Фильтр
+ public static FilterDefinition ByName(string name, string userId) =>
+ Builders.Filter.And(Builders.Filter.Eq(t => t.UserId, userId), Builders.Filter.Eq(t => t.Name, name));
+
+ ///
+ /// По книге
+ ///
+ /// Идентификатор книги
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByBook(string bookId, string userId) =>
+ Builders.Filter.And(Builders.Filter.Eq(t => t.BookId, bookId), Builders.Filter.Eq(t => t.UserId, userId));
+
+ ///
+ /// По точному совпадению
+ ///
+ /// Идентификатор книги
+ /// Идентификатор пользователя
+ /// Имя тега
+ /// Фильтр
+ public static FilterDefinition Exact(string bookId, string userId, string name) =>
+ Builders.Filter.And(
+ Builders.Filter.Eq(t => t.BookId, bookId),
+ Builders.Filter.Eq(t => t.UserId, userId),
+ Builders.Filter.Eq(t => t.Name, name));
+
+ ///
+ /// По книгам
+ ///
+ /// Идентификаторы книг
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByBooks(IEnumerable bookIds, string userId) =>
+ Builders.Filter.And(Builders.Filter.In(t => t.BookId, bookIds), Builders.Filter.Eq(t => t.UserId, userId));
+ }
+
+ ///
+ /// Избранные книги
+ ///
+ public static class FavoriteBooks
+ {
+ ///
+ /// По пользователю
+ ///
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByUser(string userId) => Builders.Filter.Eq(t => t.UserId, userId);
+
+ ///
+ /// По книге
+ ///
+ /// Идентификатор книги
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByBook(string bookId, string userId) =>
+ Builders.Filter.And(Builders.Filter.Eq(t => t.BookId, bookId), Builders.Filter.Eq(t => t.UserId, userId));
+
+ ///
+ /// По книгам
+ ///
+ /// Идентификаторы книг
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByBooks(IEnumerable bookIds, string userId) =>
+ Builders.Filter.And(Builders.Filter.In(t => t.BookId, bookIds), Builders.Filter.Eq(t => t.UserId, userId));
+ }
+
+ ///
+ /// Избранные авторы
+ ///
+ public static class FavoriteAuthors
+ {
+ ///
+ /// По пользователю
+ ///
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByUser(string userId) => Builders.Filter.Eq(t => t.UserId, userId);
+
+ ///
+ /// По точному совпадению
+ ///
+ /// Идентификатор автора
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition Exact(string authorId, string userId) =>
+ Builders.Filter.And(
+ Builders.Filter.Eq(t => t.AuthorId, authorId),
+ Builders.Filter.Eq(t => t.UserId, userId));
+ }
+
+ ///
+ /// Заблокированные книги
+ ///
+ public static class DisgustingBooks
+ {
+ ///
+ /// По пользователю
+ ///
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByUser(string userId) => Builders.Filter.Eq(t => t.UserId, userId);
+
+ ///
+ /// По книге
+ ///
+ /// Идентификатор книги
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByBook(string bookId, string userId) =>
+ Builders.Filter.And(Builders.Filter.Eq(t => t.BookId, bookId), Builders.Filter.Eq(t => t.UserId, userId));
+
+ ///
+ /// По книгам
+ ///
+ /// Идентификаторы книг
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByBooks(IEnumerable bookIds, string userId) =>
+ Builders.Filter.And(Builders.Filter.In(t => t.BookId, bookIds), Builders.Filter.Eq(t => t.UserId, userId));
+ }
+
+ ///
+ /// Заблокированные авторы
+ ///
+ public static class DisgustingAuthors
+ {
+ ///
+ /// По пользователю
+ ///
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByUser(string userId) => Builders.Filter.Eq(t => t.UserId, userId);
+
+ ///
+ /// По автору
+ ///
+ /// Идентификатор автора
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByAuthor(string authorId, string userId) =>
+ Builders.Filter.And(Builders.Filter.Eq(t => t.AuthorId, authorId), Builders.Filter.Eq(t => t.UserId, userId));
+
+ ///
+ /// По авторам
+ ///
+ /// Идентификаторы авторов
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByAuthors(IEnumerable authorIds, string userId) =>
+ Builders.Filter.And(Builders.Filter.In(t => t.AuthorId, authorIds), Builders.Filter.Eq(t => t.UserId, userId));
+ }
+
+ ///
+ /// Книги
+ ///
+ public static class Books
+ {
+ ///
+ /// По идентификаторам книг
+ ///
+ /// Идентификаторы книг
+ /// Фильтр
+ public static FilterDefinition ByIds(IEnumerable bookIds) => Builders.Filter.In(t => t.Id, bookIds);
+
+ ///
+ /// По идентификаторам авторов
+ ///
+ /// Идентификаторы авторов
+ /// Фильтр
+ public static FilterDefinition ByAuthors(IEnumerable authorIds) => Builders.Filter.AnyIn(b => b.AuthorIds, authorIds);
+
+ ///
+ /// По идентификатору автора
+ ///
+ /// Идентификатор автора
+ /// Фильтр
+ public static FilterDefinition ByAuthor(string authorId) => Builders.Filter.AnyEq(b => b.AuthorIds, authorId);
+
+ ///
+ /// По размещению в архиве
+ ///
+ /// Путь к акрхиву
+ /// Индекс в акрхиве
+ /// Фильтр
+ public static FilterDefinition ByArchiveLocation(string archivePath, int archiveIndex) =>
+ Builders.Filter.And(Builders.Filter.Eq(b => b.ArchivePath, archivePath), Builders.Filter.Eq(b => b.ArchiveIndex, archiveIndex));
+ }
+
+ ///
+ /// Книги для чтения
+ ///
+ public static class BooksToRead
+ {
+ ///
+ /// По пользователю
+ ///
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition ByUser(string userId) => Builders.Filter.Eq(t => t.UserId, userId);
+
+ ///
+ /// По точному совпадению
+ ///
+ /// Идентификатор книги
+ /// Идентификатор пользователя
+ /// Фильтр
+ public static FilterDefinition Exact(string bookId, string userId) =>
+ Builders.Filter.And(
+ Builders.Filter.Eq(t => t.BookId, bookId),
+ Builders.Filter.Eq(t => t.UserId, userId));
+ }
+
+ ///
+ /// Авторы
+ ///
+ public static class Authors
+ {
+ ///
+ /// По идентификаторам авторов
+ ///
+ /// Идентификаторы авторов
+ /// Фильтр
+ public static FilterDefinition ByIds(IEnumerable authorIds) => Builders.Filter.In(t => t.Id, authorIds);
+
+ ///
+ /// Пустой фильтр
+ ///
+ public static FilterDefinition Empty => Builders.Filter.Empty;
+ }
+
+ ///
+ /// Жанры
+ ///
+ public static class Genres
+ {
+ ///
+ /// Пустой фильтр
+ ///
+ public static FilterDefinition Empty => Builders.Filter.Empty;
+ }
+
+ ///
+ /// Авторизация
+ ///
+ public static class Auth
+ {
+ public static FilterDefinition ByLogin(string login) => Builders.Filter.Eq(a => a.Login, login);
+ }
+ }
+}
diff --git a/src/BukiVedi.Shared/Services/Library.cs b/src/BukiVedi.Shared/Services/Library.cs
index c8f6930..41a118e 100644
--- a/src/BukiVedi.Shared/Services/Library.cs
+++ b/src/BukiVedi.Shared/Services/Library.cs
@@ -43,8 +43,8 @@ namespace BukiVedi.Shared.Services
_library = new ZipLibraryReader(_libraryPath);
_engine = new SleoEngine(AppSettings.Settings.Sleopok.Path, b => b.Id);
- var authors_count = (int)Tables.Authors.Count(Builders.Filter.Empty).Result;
- var genres_count = (int)Tables.Genres.Count(Builders.Filter.Empty).Result;
+ var authors_count = (int)Tables.Authors.Count(Filters.Authors.Empty).Result;
+ var genres_count = (int)Tables.Genres.Count(Filters.Genres.Empty).Result;
Authors = new Dictionary(authors_count);
Genres = new Dictionary(genres_count);
@@ -85,18 +85,19 @@ namespace BukiVedi.Shared.Services
public async Task> SearchByTagBooks(string accountId, string tagId)
{
- IEnumerable bookIds = (await Tables.UserTag.Get(Builders.Filter.And(Builders.Filter.Eq(t => t.UserId, accountId), Builders.Filter.Eq(t => t.Id, tagId))))?.Select(t => t.BookId)!;
- if (bookIds != null && bookIds.Any())
+ var tag = await Tables.UserTag.GetById(tagId);
+ var books = (await Tables.UserTag.Get(Filters.Tags.ByName(tag.Name, accountId)))?.Select(t => t.BookId)?.ToHashSet()?.ToHashSet()!;
+ if (books != null && books.Any())
{
- var filter = Builders.Filter.In(b => b.Id, bookIds);
- return await PrepareBooksByFilter(filter);
+ return await PrepareBooksByFilter(Filters.Books.ByIds(books));
}
return Enumerable.Empty();
}
public async Task> SearchFavoritesBooks(string accountId)
{
- IEnumerable bookIds = (await Tables.FavoriteBooks.Get(Builders.Filter.Eq(f => f.UserId, accountId)))?.Select(t => t.BookId)!;
+
+ IEnumerable bookIds = (await Tables.FavoriteBooks.Get(Filters.FavoriteBooks.ByUser(accountId)))?.Select(t => t.BookId)?.ToHashSet()!;
if (bookIds != null && bookIds.Any())
{
var filter = Builders.Filter.In(b => b.Id, bookIds);
@@ -107,33 +108,30 @@ namespace BukiVedi.Shared.Services
public async Task> SearchToReadBooks(string accountId)
{
- IEnumerable bookIds = (await Tables.ReadQueue.Get(Builders.Filter.Eq(d => d.UserId, accountId)))?.Select(t => t.BookId)!;
+ IEnumerable bookIds = (await Tables.ReadQueue.Get(Filters.BooksToRead.ByUser(accountId)))?.Select(t => t.BookId)?.ToHashSet()!;
if (bookIds != null && bookIds.Any())
{
- var filter = Builders.Filter.In(b => b.Id, bookIds);
- return await PrepareBooksByFilter(filter);
+ return await PrepareBooksByFilter(Filters.Books.ByIds(bookIds));
}
return Enumerable.Empty();
}
public async Task> SearchBlockedBooks(string accountId)
{
- IEnumerable bookIds = (await Tables.DisgustingBooks.Get(Builders.Filter.Eq(d => d.UserId, accountId)))?.Select(t => t.BookId)!;
+ IEnumerable bookIds = (await Tables.DisgustingBooks.Get(Filters.DisgustingBooks.ByUser(accountId)))?.Select(t => t.BookId)?.ToHashSet()!;
if (bookIds != null && bookIds.Any())
{
- var filter = Builders.Filter.In(b => b.Id, bookIds);
- return await PrepareBooksByFilter(filter);
+ return await PrepareBooksByFilter(Filters.Books.ByIds(bookIds));
}
return Enumerable.Empty();
}
public async Task> SearchFavoriteAuthorsBooks(string accountId)
{
- var authorIds = (await Tables.FavoriteAuthors.Get(Builders.Filter.Eq(f => f.UserId, accountId)))?.Select(t => t.AuthorId)?.ToHashSet();
+ var authorIds = (await Tables.FavoriteAuthors.Get(Filters.FavoriteAuthors.ByUser(accountId)))?.Select(t => t.AuthorId)?.ToHashSet()!;
if (authorIds != null && authorIds.Any())
{
- var filter = Builders.Filter.AnyIn(b => b.AuthorIds, authorIds);
- return await PrepareBooksByFilter(filter);
+ return await PrepareBooksByFilter(Filters.Books.ByAuthors(authorIds));
}
return Enumerable.Empty();
}
@@ -142,8 +140,7 @@ namespace BukiVedi.Shared.Services
{
if (string.IsNullOrWhiteSpace(author_id) == false)
{
- var filter = Builders.Filter.AnyEq(b => b.AuthorIds, author_id);
- return await PrepareBooksByFilter(filter);
+ return await PrepareBooksByFilter(Filters.Books.ByAuthor(author_id));
}
return Enumerable.Empty();
}
@@ -152,17 +149,16 @@ namespace BukiVedi.Shared.Services
{
IEnumerable bookIds;
if (string.IsNullOrWhiteSpace(tag))
- {
- bookIds = (await Tables.UserTag.Get(Builders.Filter.Eq(t => t.UserId, accountId)))?.Select(t => t.BookId)!;
+ {
+ bookIds = (await Tables.UserTag.Get(Filters.Tags.ByUser(accountId)))?.Select(t => t.BookId)?.ToHashSet()!;
}
else
{
- bookIds = (await Tables.UserTag.Get(Builders.Filter.And(Builders.Filter.Eq(t => t.UserId, accountId), Builders.Filter.Eq(t => t.Name, tag))))?.Select(t => t.BookId)!;
+ bookIds = (await Tables.UserTag.Get(Filters.Tags.ByName(tag, accountId)))?.Select(t => t.BookId)?.ToHashSet()!;
}
if (bookIds != null && bookIds.Any())
{
- var filter = Builders.Filter.In(b => b.Id, bookIds);
- return await PrepareBooksByFilter(filter);
+ return await PrepareBooksByFilter(Filters.Books.ByIds(bookIds));
}
return Enumerable.Empty();
}
@@ -244,8 +240,7 @@ namespace BukiVedi.Shared.Services
if (docs?.Any() ?? false)
{
- var booksFilter = Builders.Filter.In(b => b.Id, docs.Select(d => d.Key));
- var books = (await Tables.Books.Get(booksFilter)).ToDictionary(b => b.Id, b => b);
+ var books = (await Tables.Books.Get(Filters.Books.ByIds(docs.Select(d => d.Key)))).ToDictionary(b => b.Id, b => b);
var result = new BookEntity[books.Count];
Log.Debug($"Found {books.Count} books by query {query}");
@@ -395,8 +390,8 @@ namespace BukiVedi.Shared.Services
foreach (var zip_book in _library.ReadBooks())
{
var archive_path = Path.GetFileName(zip_book.ArchivePath);
- var book_filter = Builders.Filter.And(Builders.Filter.Eq(b => b.ArchivePath, archive_path), Builders.Filter.Eq(b => b.ArchiveIndex, zip_book.ArchiveIndex));
- if (await Tables.Books.Exists(book_filter)) continue;
+
+ if (await Tables.Books.Exists(Filters.Books.ByArchiveLocation(archive_path, zip_book.ArchiveIndex))) continue;
var author_ids = new HashSet();
var authors_list = PrepareAuthorsLine(zip_book.Authors);
@@ -442,7 +437,6 @@ namespace BukiVedi.Shared.Services
Format = zip_book.Format.ToString()
};
await Tables.Books.Write(book);
- //Console.WriteLine($"[{((authors_list?.Length > 0) ? string.Join(';', authors_list) : string.Empty)}] \"{book.Title}\"");
}
}
}
diff --git a/src/BukiVedi.Shared/Services/Mappers/BookEntityMapper.cs b/src/BukiVedi.Shared/Services/Mappers/BookEntityMapper.cs
index 6e30bc1..81c8c61 100644
--- a/src/BukiVedi.Shared/Services/Mappers/BookEntityMapper.cs
+++ b/src/BukiVedi.Shared/Services/Mappers/BookEntityMapper.cs
@@ -6,24 +6,27 @@ namespace BukiVedi.Shared.Services.Mappers
{
public class BookEntityMapper
{
- public static async Task> Map(IEnumerable books)
+ public static async Task> Map(IEnumerable books, OperationContext context)
{
var booksIds = books.Select(x => x.Id).ToList();
- var tags_list = (await Tables.UserTag.Get(Builders.Filter.In(t => t.BookId, booksIds)));
+ var tags_list = (await Tables.UserTag.Get(Filters.Tags.ByBooks(booksIds, context.OperationInitiator.Id)));
var tags = new Dictionary>();
foreach (var t in tags_list)
{
if (tags.TryGetValue(t.BookId, out var list)) { list.Add(new TagInfo { Id = t.Id, Name = t.Name }); }
else
{
- tags.Add(t.BookId,
- new List
- {
+ tags.Add(t.BookId,
+ new List
+ {
new TagInfo { Id = t.Id, Name = t.Name }
});
}
}
+ var favorites = (await Tables.FavoriteBooks.Get(Filters.FavoriteBooks.ByBooks(booksIds, context.OperationInitiator.Id)))?.Select(f => f.BookId)?.ToHashSet();
+ var blocked = (await Tables.DisgustingBooks.Get(Filters.DisgustingBooks.ByBooks(booksIds, context.OperationInitiator.Id)))?.Select(f => f.BookId)?.ToHashSet();
+
return books.Select(book =>
new BookInfo
{
@@ -34,7 +37,11 @@ namespace BukiVedi.Shared.Services.Mappers
Genres = new GenreInfo[1] { new GenreInfo { Id = book.Genre.Id, Name = book.Genre.Code } },
Title = book.Title,
Year = book.Year,
- Tags = tags.ContainsKey(book.Id) ? tags[book.Id] : null!
+ Tags = tags.ContainsKey(book.Id) ? tags[book.Id] : null!,
+ IsFavorite = favorites?.Contains(book.Id) ?? false,
+ IsBlocked = blocked?.Contains(book.Id) ?? false,
+ Series = string.Empty,
+ Subseries = string.Empty,
});
}
}
diff --git a/src/BukiVedi.Shared/bin/Debug/net8.0/BukiVedi.Shared.pdb b/src/BukiVedi.Shared/bin/Debug/net8.0/BukiVedi.Shared.pdb
index 4421d90..6d7d469 100644
Binary files a/src/BukiVedi.Shared/bin/Debug/net8.0/BukiVedi.Shared.pdb and b/src/BukiVedi.Shared/bin/Debug/net8.0/BukiVedi.Shared.pdb differ
diff --git a/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharp.pdb b/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharp.pdb
index 9ede083..e4b2fdc 100644
Binary files a/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharp.pdb and b/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharp.pdb differ
diff --git a/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharpPrebuilt.dll.config b/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharpPrebuilt.dll.config
deleted file mode 100644
index 3e0e37c..0000000
--- a/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharpPrebuilt.dll.config
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharpPrebuilt.pdb b/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharpPrebuilt.pdb
deleted file mode 100644
index b40b41d..0000000
Binary files a/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharpPrebuilt.pdb and /dev/null differ
diff --git a/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharpPrebuiltFull.pdb b/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharpPrebuiltFull.pdb
index 9589249..4cf25f9 100644
Binary files a/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharpPrebuiltFull.pdb and b/src/BukiVedi.Shared/bin/Debug/net8.0/LemmaSharpPrebuiltFull.pdb differ
diff --git a/src/BukiVedi.Shared/bin/Release/net8.0/BukiVedi.Shared.pdb b/src/BukiVedi.Shared/bin/Release/net8.0/BukiVedi.Shared.pdb
index 2aed3aa..541b879 100644
Binary files a/src/BukiVedi.Shared/bin/Release/net8.0/BukiVedi.Shared.pdb and b/src/BukiVedi.Shared/bin/Release/net8.0/BukiVedi.Shared.pdb differ
diff --git a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.AssemblyInfo.cs b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.AssemblyInfo.cs
index 62586fa..8435a9b 100644
--- a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.AssemblyInfo.cs
+++ b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.AssemblyInfo.cs
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("BukiVedi.Shared")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+112daccec93b21f74faf3a3b85b2f9a47b2ae81f")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f836c4963b5e99aa3f8cf1767a7e2475c8365585")]
[assembly: System.Reflection.AssemblyProductAttribute("BukiVedi.Shared")]
[assembly: System.Reflection.AssemblyTitleAttribute("BukiVedi.Shared")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.AssemblyInfoInputs.cache b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.AssemblyInfoInputs.cache
index d848a99..4f94007 100644
--- a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.AssemblyInfoInputs.cache
+++ b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.AssemblyInfoInputs.cache
@@ -1 +1 @@
-509bc785dfee6d2836ba0599e079958f32ff95621449af032e3881340993551e
+e4e6ef3d232779668b7356b53e736c596a60d5e2e06421f0b29dbc4bb5a419a2
diff --git a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.AssemblyReference.cache b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.AssemblyReference.cache
index fffe689..f98c015 100644
Binary files a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.AssemblyReference.cache and b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.AssemblyReference.cache differ
diff --git a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.CoreCompileInputs.cache b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.CoreCompileInputs.cache
index cb23dd3..ce56902 100644
--- a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.CoreCompileInputs.cache
+++ b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-8f1511391c660118f311ede1de029df8d3c4dca0dcff3c3fe53339a3d1836ea1
+75e2e150ecac4751ac10fab9d34f7b529ba5779544f9189c3c88503c5831419a
diff --git a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.FileListAbsolute.txt b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.FileListAbsolute.txt
index 5582748..8fb6b82 100644
--- a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.FileListAbsolute.txt
+++ b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.csproj.FileListAbsolute.txt
@@ -46,5 +46,3 @@ G:\Documents\GitHub\BukiVedi\src\BukiVedi.Shared\obj\Debug\net8.0\BukiVedi.Share
G:\Documents\GitHub\BukiVedi\src\BukiVedi.Shared\obj\Debug\net8.0\refint\BukiVedi.Shared.dll
G:\Documents\GitHub\BukiVedi\src\BukiVedi.Shared\obj\Debug\net8.0\BukiVedi.Shared.pdb
G:\Documents\GitHub\BukiVedi\src\BukiVedi.Shared\obj\Debug\net8.0\ref\BukiVedi.Shared.dll
-G:\Documents\GitHub\BukiVedi\src\BukiVedi.Shared\bin\Debug\net8.0\LemmaSharpPrebuilt.pdb
-G:\Documents\GitHub\BukiVedi\src\BukiVedi.Shared\bin\Debug\net8.0\LemmaSharpPrebuilt.dll.config
diff --git a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.pdb b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.pdb
index 4421d90..6d7d469 100644
Binary files a/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.pdb and b/src/BukiVedi.Shared/obj/Debug/net8.0/BukiVedi.Shared.pdb differ
diff --git a/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.AssemblyInfo.cs b/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.AssemblyInfo.cs
index 50fa052..be1b53c 100644
--- a/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.AssemblyInfo.cs
+++ b/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.AssemblyInfo.cs
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("BukiVedi.Shared")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+431f2503a837ccf39eac97076a865db39f86a8dd")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f836c4963b5e99aa3f8cf1767a7e2475c8365585")]
[assembly: System.Reflection.AssemblyProductAttribute("BukiVedi.Shared")]
[assembly: System.Reflection.AssemblyTitleAttribute("BukiVedi.Shared")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.AssemblyInfoInputs.cache b/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.AssemblyInfoInputs.cache
index 73796d8..f52ae82 100644
--- a/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.AssemblyInfoInputs.cache
+++ b/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.AssemblyInfoInputs.cache
@@ -1 +1 @@
-06715856c937a6aa0ade3b1fa065928029591cc434dd76545f239523dd28567b
+98f72f42fc48d45d265a5ffb52e9388479522c8b965310d02bf57c3576b0305d
diff --git a/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.csproj.AssemblyReference.cache b/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.csproj.AssemblyReference.cache
index 05631fb..a8a579a 100644
Binary files a/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.csproj.AssemblyReference.cache and b/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.csproj.AssemblyReference.cache differ
diff --git a/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.pdb b/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.pdb
index 2aed3aa..541b879 100644
Binary files a/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.pdb and b/src/BukiVedi.Shared/obj/Release/net8.0/BukiVedi.Shared.pdb differ
diff --git a/src/TitleReader/bin/Debug/net8.0/BukiVedi.Shared.pdb b/src/TitleReader/bin/Debug/net8.0/BukiVedi.Shared.pdb
index 59e76c2..6d7d469 100644
Binary files a/src/TitleReader/bin/Debug/net8.0/BukiVedi.Shared.pdb and b/src/TitleReader/bin/Debug/net8.0/BukiVedi.Shared.pdb differ
diff --git a/src/TitleReader/bin/Debug/net8.0/LemmaSharp.pdb b/src/TitleReader/bin/Debug/net8.0/LemmaSharp.pdb
index 9ede083..e4b2fdc 100644
Binary files a/src/TitleReader/bin/Debug/net8.0/LemmaSharp.pdb and b/src/TitleReader/bin/Debug/net8.0/LemmaSharp.pdb differ
diff --git a/src/TitleReader/bin/Debug/net8.0/LemmaSharpPrebuilt.dll.config b/src/TitleReader/bin/Debug/net8.0/LemmaSharpPrebuilt.dll.config
deleted file mode 100644
index 3e0e37c..0000000
--- a/src/TitleReader/bin/Debug/net8.0/LemmaSharpPrebuilt.dll.config
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/src/TitleReader/bin/Debug/net8.0/LemmaSharpPrebuilt.pdb b/src/TitleReader/bin/Debug/net8.0/LemmaSharpPrebuilt.pdb
deleted file mode 100644
index b40b41d..0000000
Binary files a/src/TitleReader/bin/Debug/net8.0/LemmaSharpPrebuilt.pdb and /dev/null differ
diff --git a/src/TitleReader/bin/Debug/net8.0/LemmaSharpPrebuiltFull.pdb b/src/TitleReader/bin/Debug/net8.0/LemmaSharpPrebuiltFull.pdb
index 9589249..4cf25f9 100644
Binary files a/src/TitleReader/bin/Debug/net8.0/LemmaSharpPrebuiltFull.pdb and b/src/TitleReader/bin/Debug/net8.0/LemmaSharpPrebuiltFull.pdb differ
diff --git a/src/TitleReader/bin/Debug/net8.0/TitleReader.pdb b/src/TitleReader/bin/Debug/net8.0/TitleReader.pdb
index db2ebb2..f582264 100644
Binary files a/src/TitleReader/bin/Debug/net8.0/TitleReader.pdb and b/src/TitleReader/bin/Debug/net8.0/TitleReader.pdb differ
diff --git a/src/TitleReader/obj/Debug/net8.0/TitleReader.AssemblyInfo.cs b/src/TitleReader/obj/Debug/net8.0/TitleReader.AssemblyInfo.cs
index 2bbecb6..d7bc413 100644
--- a/src/TitleReader/obj/Debug/net8.0/TitleReader.AssemblyInfo.cs
+++ b/src/TitleReader/obj/Debug/net8.0/TitleReader.AssemblyInfo.cs
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("TitleReader")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+112daccec93b21f74faf3a3b85b2f9a47b2ae81f")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f836c4963b5e99aa3f8cf1767a7e2475c8365585")]
[assembly: System.Reflection.AssemblyProductAttribute("TitleReader")]
[assembly: System.Reflection.AssemblyTitleAttribute("TitleReader")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/src/TitleReader/obj/Debug/net8.0/TitleReader.AssemblyInfoInputs.cache b/src/TitleReader/obj/Debug/net8.0/TitleReader.AssemblyInfoInputs.cache
index be00c73..ea274b0 100644
--- a/src/TitleReader/obj/Debug/net8.0/TitleReader.AssemblyInfoInputs.cache
+++ b/src/TitleReader/obj/Debug/net8.0/TitleReader.AssemblyInfoInputs.cache
@@ -1 +1 @@
-153deb8a7a296fdeedff24e4e5322961f1ebc6ec896447287c432b0746206083
+c9e66645ae5573f9df578f3f25060b24528e55f246ced67e86a246dab31a8f04
diff --git a/src/TitleReader/obj/Debug/net8.0/TitleReader.csproj.AssemblyReference.cache b/src/TitleReader/obj/Debug/net8.0/TitleReader.csproj.AssemblyReference.cache
index c4fb2f9..367e547 100644
Binary files a/src/TitleReader/obj/Debug/net8.0/TitleReader.csproj.AssemblyReference.cache and b/src/TitleReader/obj/Debug/net8.0/TitleReader.csproj.AssemblyReference.cache differ
diff --git a/src/TitleReader/obj/Debug/net8.0/TitleReader.csproj.FileListAbsolute.txt b/src/TitleReader/obj/Debug/net8.0/TitleReader.csproj.FileListAbsolute.txt
index 6928582..9ad9a6c 100644
--- a/src/TitleReader/obj/Debug/net8.0/TitleReader.csproj.FileListAbsolute.txt
+++ b/src/TitleReader/obj/Debug/net8.0/TitleReader.csproj.FileListAbsolute.txt
@@ -133,5 +133,3 @@ G:\Documents\GitHub\BukiVedi\src\TitleReader\obj\Debug\net8.0\refint\TitleReader
G:\Documents\GitHub\BukiVedi\src\TitleReader\obj\Debug\net8.0\TitleReader.pdb
G:\Documents\GitHub\BukiVedi\src\TitleReader\obj\Debug\net8.0\TitleReader.genruntimeconfig.cache
G:\Documents\GitHub\BukiVedi\src\TitleReader\obj\Debug\net8.0\ref\TitleReader.dll
-G:\Documents\GitHub\BukiVedi\src\TitleReader\bin\Debug\net8.0\LemmaSharpPrebuilt.pdb
-G:\Documents\GitHub\BukiVedi\src\TitleReader\bin\Debug\net8.0\LemmaSharpPrebuilt.dll.config
diff --git a/src/TitleReader/obj/Debug/net8.0/TitleReader.pdb b/src/TitleReader/obj/Debug/net8.0/TitleReader.pdb
index db2ebb2..f582264 100644
Binary files a/src/TitleReader/obj/Debug/net8.0/TitleReader.pdb and b/src/TitleReader/obj/Debug/net8.0/TitleReader.pdb differ
diff --git a/src/TitleReader/obj/Release/net8.0/TitleReader.AssemblyInfo.cs b/src/TitleReader/obj/Release/net8.0/TitleReader.AssemblyInfo.cs
index 7f9eee5..e3ec609 100644
--- a/src/TitleReader/obj/Release/net8.0/TitleReader.AssemblyInfo.cs
+++ b/src/TitleReader/obj/Release/net8.0/TitleReader.AssemblyInfo.cs
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("TitleReader")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+431f2503a837ccf39eac97076a865db39f86a8dd")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f836c4963b5e99aa3f8cf1767a7e2475c8365585")]
[assembly: System.Reflection.AssemblyProductAttribute("TitleReader")]
[assembly: System.Reflection.AssemblyTitleAttribute("TitleReader")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/src/TitleReader/obj/Release/net8.0/TitleReader.AssemblyInfoInputs.cache b/src/TitleReader/obj/Release/net8.0/TitleReader.AssemblyInfoInputs.cache
index 8cc1727..aeaa48f 100644
--- a/src/TitleReader/obj/Release/net8.0/TitleReader.AssemblyInfoInputs.cache
+++ b/src/TitleReader/obj/Release/net8.0/TitleReader.AssemblyInfoInputs.cache
@@ -1 +1 @@
-a7282ddb1bbc4aea6cf73d9f5cd24625e715891dd94841b8c41be90b8822b144
+9de5ac71286c28facdb4bb6ca86d853cad2ea78e15c3db020117cee35f3bd8ce
diff --git a/src/TitleReader/obj/Release/net8.0/TitleReader.csproj.AssemblyReference.cache b/src/TitleReader/obj/Release/net8.0/TitleReader.csproj.AssemblyReference.cache
index a22402c..163cd7a 100644
Binary files a/src/TitleReader/obj/Release/net8.0/TitleReader.csproj.AssemblyReference.cache and b/src/TitleReader/obj/Release/net8.0/TitleReader.csproj.AssemblyReference.cache differ