diff --git a/Sources/BookApp.sln b/Sources/BookApp.sln index 564ec79..e659e19 100644 --- a/Sources/BookApp.sln +++ b/Sources/BookApp.sln @@ -1,33 +1,69 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.7.34024.191 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookApp", "BookApp\BookApp.csproj", "{DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestFrontEnd", "TestFrontEnd\TestFrontEnd.csproj", "{90EE7351-A889-4CE3-B066-090931FD69C6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Release|Any CPU.Build.0 = Release|Any CPU - {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Release|Any CPU.Deploy.0 = Release|Any CPU - {90EE7351-A889-4CE3-B066-090931FD69C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {90EE7351-A889-4CE3-B066-090931FD69C6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {90EE7351-A889-4CE3-B066-090931FD69C6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {90EE7351-A889-4CE3-B066-090931FD69C6}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {27FCF0C7-3613-4FC6-9E95-2EEFB171F0F4} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34024.191 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookApp", "BookApp\BookApp.csproj", "{DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DtoAbstractLayer", "DtoAbstractLayer\DtoAbstractLayer.csproj", "{C45DF3F7-AFCA-4252-89CC-1A6E5CA9EF33}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonReader", "JsonReader\JsonReader.csproj", "{F2A0B67A-2BA9-4447-9BFD-708D430EBCFA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryDTO", "LibraryDTO\LibraryDTO.csproj", "{94F9B003-9A66-424E-9758-77D140F041BA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{70ECEB25-24E4-47AA-BA64-0F0C8C4F090F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubbedDTO", "StubbedDTO\StubbedDTO.csproj", "{B84474A1-D290-473B-AFF3-FA4ECB509024}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils", "Utils\Utils.csproj", "{03A3193F-92CC-4360-8061-E5207CC7FD2F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stub", "Stub\Stub.csproj", "{14ED7ADF-7B83-432E-A87B-40C153041067}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Release|Any CPU.Build.0 = Release|Any CPU + {DBD6BB08-83E2-42EA-A28C-32DB6959E4B5}.Release|Any CPU.Deploy.0 = Release|Any CPU + {C45DF3F7-AFCA-4252-89CC-1A6E5CA9EF33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C45DF3F7-AFCA-4252-89CC-1A6E5CA9EF33}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C45DF3F7-AFCA-4252-89CC-1A6E5CA9EF33}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C45DF3F7-AFCA-4252-89CC-1A6E5CA9EF33}.Release|Any CPU.Build.0 = Release|Any CPU + {F2A0B67A-2BA9-4447-9BFD-708D430EBCFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2A0B67A-2BA9-4447-9BFD-708D430EBCFA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2A0B67A-2BA9-4447-9BFD-708D430EBCFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2A0B67A-2BA9-4447-9BFD-708D430EBCFA}.Release|Any CPU.Build.0 = Release|Any CPU + {94F9B003-9A66-424E-9758-77D140F041BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {94F9B003-9A66-424E-9758-77D140F041BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {94F9B003-9A66-424E-9758-77D140F041BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {94F9B003-9A66-424E-9758-77D140F041BA}.Release|Any CPU.Build.0 = Release|Any CPU + {70ECEB25-24E4-47AA-BA64-0F0C8C4F090F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70ECEB25-24E4-47AA-BA64-0F0C8C4F090F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70ECEB25-24E4-47AA-BA64-0F0C8C4F090F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70ECEB25-24E4-47AA-BA64-0F0C8C4F090F}.Release|Any CPU.Build.0 = Release|Any CPU + {B84474A1-D290-473B-AFF3-FA4ECB509024}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B84474A1-D290-473B-AFF3-FA4ECB509024}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B84474A1-D290-473B-AFF3-FA4ECB509024}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B84474A1-D290-473B-AFF3-FA4ECB509024}.Release|Any CPU.Build.0 = Release|Any CPU + {03A3193F-92CC-4360-8061-E5207CC7FD2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03A3193F-92CC-4360-8061-E5207CC7FD2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03A3193F-92CC-4360-8061-E5207CC7FD2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03A3193F-92CC-4360-8061-E5207CC7FD2F}.Release|Any CPU.Build.0 = Release|Any CPU + {14ED7ADF-7B83-432E-A87B-40C153041067}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {14ED7ADF-7B83-432E-A87B-40C153041067}.Debug|Any CPU.Build.0 = Debug|Any CPU + {14ED7ADF-7B83-432E-A87B-40C153041067}.Release|Any CPU.ActiveCfg = Release|Any CPU + {14ED7ADF-7B83-432E-A87B-40C153041067}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {27FCF0C7-3613-4FC6-9E95-2EEFB171F0F4} + EndGlobalSection +EndGlobal diff --git a/Sources/DtoAbstractLayer/DtoAbstractLayer.csproj b/Sources/DtoAbstractLayer/DtoAbstractLayer.csproj new file mode 100644 index 0000000..496da7a --- /dev/null +++ b/Sources/DtoAbstractLayer/DtoAbstractLayer.csproj @@ -0,0 +1,12 @@ + + + + net7.0 + enable + enable + + + + + + diff --git a/Sources/DtoAbstractLayer/IDtoManager.cs b/Sources/DtoAbstractLayer/IDtoManager.cs new file mode 100644 index 0000000..4edf2da --- /dev/null +++ b/Sources/DtoAbstractLayer/IDtoManager.cs @@ -0,0 +1,97 @@ +using LibraryDTO; + +namespace DtoAbstractLayer; + +/// +/// abstract layer for requests on Books Library +/// +public interface IDtoManager +{ + /// + /// get a book by specifying its id + /// + /// id of the Book to get + /// a Book with this id (or null if id is unknown) + Task GetBookById(string id); + + /// + /// get a book by specifying its isbn + /// + /// isbn of the Book to get + /// a Book with this isbn (or null if isbn is unknown) + Task GetBookByISBN(string isbn); + + /// + /// get books containing a substring in their titles + /// + /// the substring to look for in book titles + /// index of the page of resulting books + /// number of resulting books per page + /// sort criterium (not mandatory): + /// + /// + /// max count books + Task>> GetBooksByTitle(string title, int index, int count, string sort = ""); + + /// + /// get books of a particular author by giving the author id + /// + /// the id of the author + /// index of the page of resulting books + /// number of resulting books per page + /// sort criterium (not mandatory): + ///
    + ///
  • ```title```: sort books by titles in alphabetical order,
  • + ///
  • ```title_reverse```: sort books by titles in reverse alphabetical order,
  • + ///
  • ```new```: sort books by publishing dates, beginning with the most recents,
  • + ///
  • ```old```: sort books by publishing dates, beginning with the oldest
  • + ///
+ /// + /// max count books + Task>> GetBooksByAuthorId(string authorId, int index, int count, string sort = ""); + + /// + /// get books of authors whose name (or alternate names) contains a particular substring + /// + /// name to look for in author names or alternate names + /// index of the page of resulting books + /// number of resulting books per page + /// sort criterium (not mandatory): + ///
    + ///
  • ```title```: sort books by titles in alphabetical order,
  • + ///
  • ```title_reverse```: sort books by titles in reverse alphabetical order,
  • + ///
  • ```new```: sort books by publishing dates, beginning with the most recents,
  • + ///
  • ```old```: sort books by publishing dates, beginning with the oldest
  • + ///
+ /// + /// max count books + Task>> GetBooksByAuthor(string author, int index, int count, string sort = ""); + + /// + /// get an author by specifying its id + /// + /// id of the Author to get + /// an author with this id (or null if id is unknown) + Task GetAuthorById(string id); + + /// + /// get authors containing a substring in their names (or alternate names) + /// + /// the substring to look for in author names (or alternate names) + /// index of the page of resulting authors + /// number of resulting authors per page + /// sort criterium (not mandatory): + ///
    + ///
  • ```name```: sort authors by names in alphabetical order,
  • + ///
  • ```name_reverse```: sort authors by names in reverse alphabetical order,
  • + ///
+ /// + /// max count authors + Task>> GetAuthorsByName(string substring, int index, int count, string sort = ""); +} + diff --git a/Sources/JsonReader/AuthorJsonReader.cs b/Sources/JsonReader/AuthorJsonReader.cs new file mode 100644 index 0000000..0ae07db --- /dev/null +++ b/Sources/JsonReader/AuthorJsonReader.cs @@ -0,0 +1,80 @@ +using System; +using LibraryDTO; +using Newtonsoft.Json.Linq; +using System.Globalization; + +namespace JsonReader +{ + public static class AuthorJsonReader + { + public static AuthorDTO ReadAuthor(string json) + { + JObject o = JObject.Parse(json); + string bioTokenAsString = null; + if(o.TryGetValue("bio", out JToken? bioToken)) + { + if(bioToken.Type == JTokenType.String) + { + bioTokenAsString = (string)bioToken; + } + else + { + var bioTokenValue = o["bio"]?["value"]; + bioTokenAsString = (string)bioTokenValue; + } + } + + AuthorDTO author = new AuthorDTO + { + Id = (string)o["key"], + Name = (string)o["name"], + Bio = bioTokenAsString, + BirthDate = o.TryGetValue("birth_date", out JToken? bd) ? ReadDate((string)o["birth_date"]) : null, + DeathDate = o.TryGetValue("death_date", out JToken? dd) ? ReadDate((string)o["death_date"]) : null, + Links = o.TryGetValue("links", out JToken? links) ? links.Select(l => new LinkDTO { Title = (string)l["title"], Url = (string)l["url"] }).ToList() : new List(), + AlternateNames = o.TryGetValue("alternate_names", out JToken? altNames) ? altNames.Select(alt => (string)alt).ToList() : new List() + }; + return author; + } + + public static DateTime? ReadDate(string dateInJson) + { + if(dateInJson == null) return null; + + List> pubDateFormat =new List>() + { + Tuple.Create("d MMMM yyyy", CultureInfo.GetCultureInfo("fr-FR")), + Tuple.Create("d MMMM yyyy", CultureInfo.InvariantCulture), + Tuple.Create("MMM dd, yyyy", CultureInfo.InvariantCulture) + }; + + DateTime? publishDate = null; + foreach(var format in pubDateFormat) + { + if(DateTime.TryParseExact(dateInJson, format.Item1, format.Item2, DateTimeStyles.None, out DateTime readDate)) + { + publishDate = readDate; + break; + } + } + if(!publishDate.HasValue && int.TryParse(dateInJson, out int year)) + { + publishDate = new DateTime(year, 12, 31); + } + return publishDate; + } + + public static Tuple> GetAuthorsByName(string json) + { + JObject o = JObject.Parse(json); + long numFound = (long)o["numFound"]; + var authors = o["docs"].Select(doc => new AuthorDTO + { + Id = $"/authors/{(string)doc["key"]}", + Name = (string)doc["name"], + }); + return Tuple.Create(numFound, authors); + } + } +} + diff --git a/Sources/JsonReader/BookJsonReader.cs b/Sources/JsonReader/BookJsonReader.cs new file mode 100644 index 0000000..ab2a87e --- /dev/null +++ b/Sources/JsonReader/BookJsonReader.cs @@ -0,0 +1,97 @@ +using System.Globalization; +using LibraryDTO; +using Newtonsoft.Json.Linq; + +namespace JsonReader; + +public static class BookJsonReader +{ + static Dictionary languages = new Dictionary() + { + [@"/languages/fre"] = Languages.French, + [@"/languages/eng"] = Languages.English, + ["fre"] = Languages.French, + ["eng"] = Languages.English, + [""] = Languages.Unknown + }; + + public static BookDTO ReadBook(string json) + { + JObject o = JObject.Parse(json); + var l = o["languages"]?.FirstOrDefault(""); + Languages lang = l != null ? languages[(string)l["key"]] : Languages.Unknown; + //List> pubDateFormat =new List>() + //{ + // Tuple.Create("d MMMM yyyy", CultureInfo.GetCultureInfo("fr-FR")), + // Tuple.Create("MMM dd, yyyy", CultureInfo.InvariantCulture) + //}; + + //DateTime? publishDate = null; + //foreach(var format in pubDateFormat) + //{ + // if(DateTime.TryParseExact((string)o["publish_date"], format.Item1, format.Item2, DateTimeStyles.None, out DateTime readDate)) + // { + // publishDate = readDate; + // break; + // } + //} + //if(!publishDate.HasValue) + //{ + // publishDate = new DateTime((int)o["publish_date"], 12, 31); + //} + DateTime? publishDate = AuthorJsonReader.ReadDate((string)o["publish_date"]); + + BookDTO book = new BookDTO + { + Id = (string)o["key"], + Title = (string)o["title"], + Publishers = o["publishers"].Select(p => (string)p).ToList(), + PublishDate = publishDate.GetValueOrDefault(DateTime.Now), + ISBN13 = (string)o["isbn_13"][0], + NbPages = o["number_of_pages"] != null ? (int)o["number_of_pages"] : -1, + Language = lang, + Format = o.TryGetValue("physical_format", out JToken? f) ? (string)f : null, + Works = o["works"].Select(w => new WorkDTO { Id = (string)w["key"] }).ToList(), + Contributors = o.TryGetValue("contributors", out JToken? contr) ? contr.Select(c => new ContributorDTO { Name = (string)c["name"], Role = (string)c["role"] }).ToList() : new List(), + Authors = o["authors"]?.Select(a => new AuthorDTO { Id = (string)a["key"] }).ToList() + }; + if(book.Authors == null) + { + book.Authors = new List(); + } + return book; + } + + public static Tuple> GetBooksByAuthor(string json) + { + JObject o = JObject.Parse(json); + long numFound = (long)o["numFound"]; + var books = o["docs"].Select(doc => new BookDTO + { + Id = (string)(doc["seed"].First()), + Title = (string)doc["title"], + ISBN13 = (string)(doc["isbn"].First()), + Authors = doc["seed"].Where(s => ((string)s).StartsWith("/authors/")) + .Select(s => new AuthorDTO { Id = (string)s }).ToList(), + Language = languages.GetValueOrDefault((string)(doc["language"].First())) + }); + return Tuple.Create(numFound, books); + } + + public static Tuple> GetBooksByTitle(string json) + { + JObject o = JObject.Parse(json); + long numFound = (long)o["numFound"]; + var books = o["docs"].Select(doc => new BookDTO + { + Id = (string)(doc["seed"].First()), + Title = (string)doc["title"], + ISBN13 = (string)(doc["isbn"].First()), + Authors = doc["seed"].Where(s => ((string)s).StartsWith("/authors/")) + .Select(s => new AuthorDTO { Id = (string)s }).ToList(), + Language = languages.GetValueOrDefault((string)(doc["language"].First())) + }); + return Tuple.Create(numFound, books); + } +} + diff --git a/Sources/JsonReader/JsonReader.csproj b/Sources/JsonReader/JsonReader.csproj new file mode 100644 index 0000000..8e77096 --- /dev/null +++ b/Sources/JsonReader/JsonReader.csproj @@ -0,0 +1,15 @@ + + + + net7.0 + enable + enable + + + + + + + + + diff --git a/Sources/JsonReader/WorkJsonReader.cs b/Sources/JsonReader/WorkJsonReader.cs new file mode 100644 index 0000000..387dbbd --- /dev/null +++ b/Sources/JsonReader/WorkJsonReader.cs @@ -0,0 +1,55 @@ +using System; +using LibraryDTO; +using Newtonsoft.Json.Linq; +using System.Globalization; + +namespace JsonReader +{ + public static class WorkJsonReader + { + public static WorkDTO ReadWork(string json, string ratingsJson) + { + JObject o = JObject.Parse(json); + JObject r = JObject.Parse(ratingsJson); + var ratingsDto = new RatingsDTO(); + if(r["summary"]["average"].Type != JTokenType.Float) + { + ratingsDto.Average = -1; + ratingsDto.Count = 0; + } + else + { + ratingsDto.Average = (float)r["summary"]["average"]; + ratingsDto.Count = (int)r["summary"]["count"]; + } + + string description = null; + if(o.TryGetValue("description", out JToken? descr)) + { + if(descr.Type == JTokenType.String) + { + description = (string)descr; + } + else + { + if (descr["value"].Type == JTokenType.String) + { + description = (string)descr["value"]; + } + } + } + + WorkDTO work = new WorkDTO + { + Id = (string)o["key"], + Title = (string)o["title"], + Authors = o.TryGetValue("authors", out JToken? authors) ? authors.Select(a => new AuthorDTO { Id = (string)a["author"]["key"] }).ToList() : new List(), + Description = description, + Subjects = o.TryGetValue("subjects", out JToken? subjects) ? subjects.Select(s => (string)s).ToList() : new List(), + Ratings = ratingsDto + }; + return work; + } + } +} + diff --git a/Sources/LibraryDTO/AuthorDTO.cs b/Sources/LibraryDTO/AuthorDTO.cs new file mode 100644 index 0000000..22376e7 --- /dev/null +++ b/Sources/LibraryDTO/AuthorDTO.cs @@ -0,0 +1,18 @@ +using System; +namespace LibraryDTO +{ + public class AuthorDTO + { + public string Id { get; set; } + public string Name { get; set; } + public string ImageSmall => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-S.jpg"; + public string ImageMedium => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-M.jpg"; + public string ImageLarge => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-L.jpg"; + public string Bio { get; set; } + public List AlternateNames { get; set; } = new List(); + public List Links { get; set; } + public DateTime? BirthDate { get; set; } + public DateTime? DeathDate { get; set; } + } +} + diff --git a/Sources/LibraryDTO/BookDTO.cs b/Sources/LibraryDTO/BookDTO.cs new file mode 100644 index 0000000..a260ae0 --- /dev/null +++ b/Sources/LibraryDTO/BookDTO.cs @@ -0,0 +1,23 @@ +using System; +namespace LibraryDTO +{ + public class BookDTO + { + public string Id { get; set; } + public string Title { get; set; } + public List Publishers { get; set; } = new List(); + public DateTime PublishDate { get; set; } + public string ISBN13 { get; set; } + public List Series { get; set; } = new List(); + public int NbPages { get; set; } + public string Format { get; set; } + public Languages Language { get; set; } + public List Contributors { get; set; } + public string ImageSmall => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-S.jpg"; + public string ImageMedium => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-M.jpg"; + public string ImageLarge => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-L.jpg"; + public List Works { get; set; } = new List(); + public List Authors { get; set; } = new List(); + } +} + diff --git a/Sources/LibraryDTO/ContributorDTO.cs b/Sources/LibraryDTO/ContributorDTO.cs new file mode 100644 index 0000000..beab5d1 --- /dev/null +++ b/Sources/LibraryDTO/ContributorDTO.cs @@ -0,0 +1,10 @@ +using System; +namespace LibraryDTO +{ + public class ContributorDTO + { + public string Name { get; set; } + public string Role { get; set; } + } +} + diff --git a/Sources/LibraryDTO/Languages.cs b/Sources/LibraryDTO/Languages.cs new file mode 100644 index 0000000..fcf51b5 --- /dev/null +++ b/Sources/LibraryDTO/Languages.cs @@ -0,0 +1,11 @@ +using System; +namespace LibraryDTO +{ + public enum Languages + { + Unknown, + French, + English + } +} + diff --git a/Sources/LibraryDTO/LibraryDTO.csproj b/Sources/LibraryDTO/LibraryDTO.csproj new file mode 100644 index 0000000..ef76c53 --- /dev/null +++ b/Sources/LibraryDTO/LibraryDTO.csproj @@ -0,0 +1,18 @@ + + + + net7.0 + enable + enable + + + + 4 + bin\Debug\net7.0\LibraryDTO.xml + + + true + 4 + bin\Release\net7.0\LibraryDTO.xml + + diff --git a/Sources/LibraryDTO/LinkDTO.cs b/Sources/LibraryDTO/LinkDTO.cs new file mode 100644 index 0000000..336909c --- /dev/null +++ b/Sources/LibraryDTO/LinkDTO.cs @@ -0,0 +1,10 @@ +using System; +namespace LibraryDTO +{ + public class LinkDTO + { + public string Title { get; set; } + public string Url { get; set; } + } +} + diff --git a/Sources/LibraryDTO/RatingsDTO.cs b/Sources/LibraryDTO/RatingsDTO.cs new file mode 100644 index 0000000..f15e5eb --- /dev/null +++ b/Sources/LibraryDTO/RatingsDTO.cs @@ -0,0 +1,10 @@ +using System; +namespace LibraryDTO +{ + public class RatingsDTO + { + public float Average { get; set; } + public int Count { get; set; } + } +} + diff --git a/Sources/LibraryDTO/WorkDTO.cs b/Sources/LibraryDTO/WorkDTO.cs new file mode 100644 index 0000000..2c41813 --- /dev/null +++ b/Sources/LibraryDTO/WorkDTO.cs @@ -0,0 +1,14 @@ +using System; +namespace LibraryDTO +{ + public class WorkDTO + { + public string Id { get; set; } + public string Description { get; set; } + public string Title { get; set; } + public List Subjects { get; set; } = new List(); + public List Authors { get; set; } = new List(); + public RatingsDTO Ratings { get; set; } + } +} + diff --git a/Sources/Model/Author.cs b/Sources/Model/Author.cs new file mode 100644 index 0000000..05f422c --- /dev/null +++ b/Sources/Model/Author.cs @@ -0,0 +1,18 @@ +using System; +namespace Model +{ + public class Author + { + public string Id { get; set; } + public string Name { get; set; } + public string ImageSmall => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-S.jpg"; + public string ImageMedium => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-M.jpg"; + public string ImageLarge => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-L.jpg"; + public string Bio { get; set; } + public List AlternateNames { get; set; } = new List(); + public List Links { get; set; } + public DateTime? BirthDate { get; set; } + public DateTime? DeathDate { get; set; } + } +} + diff --git a/Sources/Model/Book.cs b/Sources/Model/Book.cs new file mode 100644 index 0000000..5c6f673 --- /dev/null +++ b/Sources/Model/Book.cs @@ -0,0 +1,23 @@ +using static Model.Book; + +namespace Model; + +public class Book +{ + public string Id { get; set; } + public string Title { get; set; } + public List Publishers { get; set; } = new List(); + public DateTime PublishDate { get; set; } + public string ISBN13 { get; set; } + public List Series { get; set; } = new List(); + public int NbPages { get; set; } + public string Format { get; set; } + public Languages Language { get; set; } + public List Contributors { get; set; } + public string ImageSmall => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-S.jpg"; + public string ImageMedium => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-M.jpg"; + public string ImageLarge => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-L.jpg"; + public List Works { get; set; } = new List(); + public List Authors { get; set; } = new List(); +} + diff --git a/Sources/Model/Borrowing.cs b/Sources/Model/Borrowing.cs new file mode 100644 index 0000000..d051b03 --- /dev/null +++ b/Sources/Model/Borrowing.cs @@ -0,0 +1,14 @@ +using System; +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace Model +{ + public class Borrowing //emprunt + { + public string Id { get; set; } + public Person Owner { get; set; } + public DateTime BorrowedAt { get; set; } + public DateTime? ReturnedAt { get; set; } + } +} + diff --git a/Sources/Model/Contributor.cs b/Sources/Model/Contributor.cs new file mode 100644 index 0000000..d1b5c12 --- /dev/null +++ b/Sources/Model/Contributor.cs @@ -0,0 +1,10 @@ +using System; +namespace Model +{ + public class Contributor + { + public string Name { get; set; } + public string Role { get; set; } + } +} + diff --git a/Sources/Model/ILibraryManager.cs b/Sources/Model/ILibraryManager.cs new file mode 100644 index 0000000..8edc427 --- /dev/null +++ b/Sources/Model/ILibraryManager.cs @@ -0,0 +1,15 @@ +using System; +namespace Model +{ + public interface ILibraryManager + { + Task GetBookById(string id); + Task GetBookByISBN(string isbn); + Task>> GetBooksByTitle(string title, int index, int count, string sort = ""); + Task>> GetBooksByAuthorId(string authorId, int index, int count, string sort = ""); + Task>> GetBooksByAuthor(string author, int index, int count, string sort = ""); + Task GetAuthorById(string id); + Task>> GetAuthorsByName(string substring, int index, int count, string sort = ""); + } +} + diff --git a/Sources/Model/IUserLibraryManager.cs b/Sources/Model/IUserLibraryManager.cs new file mode 100644 index 0000000..163c071 --- /dev/null +++ b/Sources/Model/IUserLibraryManager.cs @@ -0,0 +1,9 @@ +using System; +namespace Model +{ + public interface IUserLibraryManager : ILibraryManager + { + Task>> GetAllBooks(int index, int count, string sort = ""); + } +} + diff --git a/Sources/Model/Languages.cs b/Sources/Model/Languages.cs new file mode 100644 index 0000000..d5c2014 --- /dev/null +++ b/Sources/Model/Languages.cs @@ -0,0 +1,11 @@ +using System; +namespace Model +{ + public enum Languages + { + Unknown, + French, + English + } +} + diff --git a/Sources/Model/Link.cs b/Sources/Model/Link.cs new file mode 100644 index 0000000..04afed9 --- /dev/null +++ b/Sources/Model/Link.cs @@ -0,0 +1,10 @@ +using System; +namespace Model +{ + public class Link + { + public string Title { get; set; } + public string Url { get; set; } + } +} + diff --git a/Sources/Model/Loan.cs b/Sources/Model/Loan.cs new file mode 100644 index 0000000..0e25755 --- /dev/null +++ b/Sources/Model/Loan.cs @@ -0,0 +1,12 @@ +using System; +namespace Model +{ + public class Loan //prêt + { + public string Id { get; set; } + public Person Loaner { get; set; } + public DateTime LoanedAt { get; set; } + public DateTime? ReturnedAt { get; set; } + } +} + diff --git a/Sources/Model/Manager.cs b/Sources/Model/Manager.cs new file mode 100644 index 0000000..b66e61e --- /dev/null +++ b/Sources/Model/Manager.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.ObjectModel; +using System.Reflection; + +namespace Model +{ + public class Manager + { + private ILibraryManager LibraryManager { get; set; } + + public ReadOnlyCollection Books { get; private set; } + private List books = new(); + + public Manager(ILibraryManager libMgr) + { + LibraryManager = libMgr; + Books = new ReadOnlyCollection(books); + } + + public async Task GetBookById(string id) + => await LibraryManager.GetBookById(id); + + public async Task GetBookByISBN(string isbn) + => await LibraryManager.GetBookByISBN(isbn); + + public async Task<(long count, IEnumerable books)> GetBooksByTitle(string title, int index, int count, string sort = "") + { + var result = await LibraryManager.GetBooksByTitle(title, index, count, sort); + return (result.Item1, result.Item2); + } + + public async Task<(long count, IEnumerable books)> GetBooksByAuthorId(string authorId, int index, int count, string sort = "") + { + var result = await LibraryManager.GetBooksByAuthorId(authorId, index, count, sort); + return (result.Item1, result.Item2); + } + + public async Task<(long count, IEnumerable books)> GetBooksByAuthor(string author, int index, int count, string sort = "") + { + var result = await LibraryManager.GetBooksByAuthor(author, index, count, sort); + return (result.Item1, result.Item2); + } + + public async Task GetAuthorById(string id) + => await LibraryManager.GetAuthorById(id); + + public async Task<(long count, IEnumerable authors)> GetAuthorsByName(string substring, int index, int count, string sort = "") + { + var result = await LibraryManager.GetAuthorsByName(substring, index, count, sort); + return (result.Item1, result.Item2); + } + } +} + diff --git a/Sources/Model/Model.csproj b/Sources/Model/Model.csproj new file mode 100644 index 0000000..4658cbf --- /dev/null +++ b/Sources/Model/Model.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + + diff --git a/Sources/Model/Person.cs b/Sources/Model/Person.cs new file mode 100644 index 0000000..69daff8 --- /dev/null +++ b/Sources/Model/Person.cs @@ -0,0 +1,10 @@ +using System; +namespace Model +{ + public class Person + { + public string Id { get; set; } + public string Name { get; set; } + } +} + diff --git a/Sources/Model/Ratings.cs b/Sources/Model/Ratings.cs new file mode 100644 index 0000000..9579f4c --- /dev/null +++ b/Sources/Model/Ratings.cs @@ -0,0 +1,10 @@ +using System; +namespace Model +{ + public class Ratings + { + public float Average { get; set; } + public int Count { get; set; } + } +} + diff --git a/Sources/Model/Work.cs b/Sources/Model/Work.cs new file mode 100644 index 0000000..76d43a8 --- /dev/null +++ b/Sources/Model/Work.cs @@ -0,0 +1,14 @@ +using System; +namespace Model +{ + public class Work + { + public string Id { get; set; } + public string Description { get; set; } + public string Title { get; set; } + public List Subjects { get; set; } = new List(); + public List Authors { get; set; } = new List(); + public Ratings Ratings { get; set; } + } +} + diff --git a/Sources/Stub/EnumsMapper.cs b/Sources/Stub/EnumsMapper.cs new file mode 100644 index 0000000..95edef2 --- /dev/null +++ b/Sources/Stub/EnumsMapper.cs @@ -0,0 +1,49 @@ +using System; +using Utils; + +namespace Stub +{ + static class EnumsMapper + { + public static EnumsMapper BiddingsMapper { get; } + = new EnumsMapper( + Tuple.Create(Model.Languages.Unknown, LibraryDTO.Languages.Unknown), + Tuple.Create(Model.Languages.French, LibraryDTO.Languages.French), + Tuple.Create(Model.Languages.English, LibraryDTO.Languages.English) + ); + + public static TModel ToModel(this TDTO dto) where TModel : Enum + where TDTO : Enum + { + foreach(var prop in typeof(EnumsMapper).GetProperties()) + { + if(prop.PropertyType.Equals(typeof(EnumsMapper))) + { + return (prop.GetValue(null) as EnumsMapper).GetModel(dto); + } + } + return default(TModel); + } + + public static Model.Languages ToModel(this LibraryDTO.Languages dto) + => ToModel(dto); + + public static TDTO ToDTO(this TModel model) where TModel : Enum + where TDTO : Enum + { + foreach(var prop in typeof(EnumsMapper).GetProperties()) + { + if(prop.PropertyType.Equals(typeof(EnumsMapper))) + { + return (prop.GetValue(null) as EnumsMapper).GetEntity(model); + } + } + return default(TDTO); + } + + public static LibraryDTO.Languages ToDTO(this Model.Languages model) + => ToDTO(model); + } + +} + diff --git a/Sources/Stub/Extensions.cs b/Sources/Stub/Extensions.cs new file mode 100644 index 0000000..a4abb02 --- /dev/null +++ b/Sources/Stub/Extensions.cs @@ -0,0 +1,93 @@ +using System; +using LibraryDTO; +using Model; +using static Stub.Mapper; + +namespace Stub +{ + public static class Extensions + { + public static Ratings ToPoco(this RatingsDTO dto) + => new Ratings() { Average = dto.Average, Count = dto.Count }; + public static IEnumerable ToPocos(this IEnumerable dtos) + => dtos.Select(dto => dto.ToPoco()); + + public static Contributor ToPoco(this ContributorDTO dto) + => new Contributor { Name = dto.Name, Role = dto.Role }; + public static IEnumerable ToPocos(this IEnumerable dtos) + => dtos.Select(dto => dto.ToPoco()); + + public static Link ToPoco(this LinkDTO dto) + => new Link { Title = dto.Title, Url = dto.Url }; + public static IEnumerable ToPocos(this IEnumerable dtos) + => dtos.Select(dto => dto.ToPoco()); + + public static Author ToPoco(this AuthorDTO dto) + { + var result = AuthorsMapper.GetT(dto); + if(result == null) + { + result = new Author + { + AlternateNames = dto.AlternateNames, + Bio = dto.Bio, + BirthDate = dto.BirthDate, + DeathDate = dto.DeathDate, + Id = dto.Id, + Links = dto.Links.ToPocos().ToList(), + Name = dto.Name + }; + } + return result; + } + public static IEnumerable ToPocos(this IEnumerable dtos) + => dtos.Select(dto => dto.ToPoco()); + + public static Work ToPoco(this WorkDTO dto) + { + var result = WorksMapper.GetT(dto); + if(result == null) + { + result = new Work + { + Authors = dto.Authors.ToPocos().ToList(), + Description = dto.Description, + Id = dto.Id, + Ratings = dto.Ratings.ToPoco(), + Subjects = dto.Subjects, + Title = dto.Title + }; + } + return result; + } + public static IEnumerable ToPocos(this IEnumerable dtos) + => dtos.Select(dto => dto.ToPoco()); + + public static Book ToPoco(this BookDTO dto) + { + var result = BooksMapper.GetT(dto); + if(result == null) + { + result = new Book + { + Authors = dto.Authors.ToPocos().ToList(), + Contributors = dto.Contributors.ToPocos().ToList(), + Format = dto.Format, + Id = dto.Id, + ISBN13 = dto.ISBN13, + Language = dto.Language.ToModel(), + NbPages = dto.NbPages, + PublishDate = dto.PublishDate, + Publishers = dto.Publishers, + Series = dto.Series, + Title = dto.Title, + Works = dto.Works.ToPocos().ToList() + }; + } + return result; + } + public static IEnumerable ToPocos(this IEnumerable dtos) + => dtos.Select(dto => dto.ToPoco()); + } +} + diff --git a/Sources/Stub/Mapper.cs b/Sources/Stub/Mapper.cs new file mode 100644 index 0000000..1b2fc16 --- /dev/null +++ b/Sources/Stub/Mapper.cs @@ -0,0 +1,25 @@ +using System; +using static System.Collections.Specialized.BitVector32; +using System.Numerics; +using Utils; +using Model; +using LibraryDTO; + +namespace Stub +{ + static class Mapper + { + internal static Mapper AuthorsMapper { get; } = new Mapper(); + internal static Mapper WorksMapper { get; } = new Mapper(); + internal static Mapper BooksMapper { get; } = new Mapper(); + + internal static void Reset() + { + AuthorsMapper.Reset(); + WorksMapper.Reset(); + BooksMapper.Reset(); + } + } + +} + diff --git a/Sources/Stub/Stub.cs b/Sources/Stub/Stub.cs new file mode 100644 index 0000000..ee8a432 --- /dev/null +++ b/Sources/Stub/Stub.cs @@ -0,0 +1,49 @@ +using Model; +using Stub; + +namespace StubLib; + +public class LibraryStub : ILibraryManager +{ + private StubbedDTO.Stub StubDTO { get; set; } = new StubbedDTO.Stub(); + + public async Task GetAuthorById(string id) + { + return (await StubDTO.GetAuthorById(id)).ToPoco(); + } + + public async Task>> GetAuthorsByName(string substring, int index, int count, string sort = "") + { + var result = await StubDTO.GetAuthorsByName(substring, index, count, sort); + return Tuple.Create(result.Item1, result.Item2.ToPocos()); + } + + public async Task GetBookById(string id) + { + return (await StubDTO.GetBookById(id)).ToPoco(); + } + + public async Task GetBookByISBN(string isbn) + { + return (await StubDTO.GetBookByISBN(isbn)).ToPoco(); + } + + public async Task>> GetBooksByAuthor(string author, int index, int count, string sort = "") + { + var result = await StubDTO.GetBooksByAuthor(author, index, count, sort); + return Tuple.Create(result.Item1, result.Item2.ToPocos()); + } + + public async Task>> GetBooksByAuthorId(string authorId, int index, int count, string sort = "") + { + var result = await StubDTO.GetBooksByAuthor(authorId, index, count, sort); + return Tuple.Create(result.Item1, result.Item2.ToPocos()); + } + + public async Task>> GetBooksByTitle(string title, int index, int count, string sort = "") + { + var result = await StubDTO.GetBooksByTitle(title, index, count, sort); + return Tuple.Create(result.Item1, result.Item2.ToPocos()); + } +} + diff --git a/Sources/Stub/Stub.csproj b/Sources/Stub/Stub.csproj new file mode 100644 index 0000000..f70ca4b --- /dev/null +++ b/Sources/Stub/Stub.csproj @@ -0,0 +1,14 @@ + + + + net7.0 + enable + enable + + + + + + + + diff --git a/Sources/StubbedDTO/Stub.cs b/Sources/StubbedDTO/Stub.cs new file mode 100644 index 0000000..2eebcb2 --- /dev/null +++ b/Sources/StubbedDTO/Stub.cs @@ -0,0 +1,203 @@ +using System.Data.SqlTypes; +using DtoAbstractLayer; +using JsonReader; +using LibraryDTO; +using static System.Reflection.Metadata.BlobBuilder; + +namespace StubbedDTO; + +public class Stub : IDtoManager +{ + public static List Authors { get; set; } = new List(); + + public static List Books { get; set; } = new List(); + + public static List Works { get; set; } = new List(); + + public static string BasePath { get; set; } = ""; + + static Stub() + { + foreach(var fileAuthor in new DirectoryInfo($"{BasePath}authors/").GetFiles()) + { + using(StreamReader reader = File.OpenText(fileAuthor.FullName)) + { + Authors.Add(AuthorJsonReader.ReadAuthor(reader.ReadToEnd())); + } + } + + foreach(var fileWork in new DirectoryInfo($"{BasePath}works/").GetFiles()) + { + var ratingsFile = $"{BasePath}ratings/{fileWork.Name.Insert((int)(fileWork.Name.Length - fileWork.Extension.Length), ".ratings")}"; + using(StreamReader reader = File.OpenText(fileWork.FullName)) + using(StreamReader readerRatings = File.OpenText(ratingsFile)) + { + var work = WorkJsonReader.ReadWork(reader.ReadToEnd(), readerRatings.ReadToEnd()); + if(work.Authors != null) + foreach(var author in work.Authors.ToList()) + { + var newAuthor = Authors.SingleOrDefault(a => a.Id == author.Id); + work.Authors.Remove(author); + work.Authors.Add(newAuthor); + } + Works.Add(work); + } + } + + foreach(var fileBook in new DirectoryInfo($"{BasePath}books/").GetFiles()) + { + using(StreamReader reader = File.OpenText(fileBook.FullName)) + { + var book = BookJsonReader.ReadBook(reader.ReadToEnd()); + foreach(var author in book.Authors.ToList()) + { + var newAuthor = Authors.SingleOrDefault(a => a.Id == author.Id); + book.Authors.Remove(author); + book.Authors.Add(newAuthor); + } + foreach(var work in book.Works.ToList()) + { + var newWork = Works.SingleOrDefault(w => w.Id == work.Id); + book.Works.Remove(work); + book.Works.Add(newWork); + } + Books.Add(book); + } + } + + } + + public Task GetAuthorById(string id) + { + var author = Stub.Authors.SingleOrDefault(a => a.Id.Contains(id)); + return Task.FromResult(author); + } + + private Task>> OrderAuthors(IEnumerable authors, int index, int count, string sort = "") + { + switch(sort) + { + case "name": + authors = authors.OrderBy(a => a.Name); + break; + case "name_reverse": + authors = authors.OrderByDescending(a => a.Name); + break; + } + return Task.FromResult(Tuple.Create((long)authors.Count(), authors.Skip(index*count).Take(count))); + } + + public async Task>> GetAuthors(int index, int count, string sort = "") + { + IEnumerable authors = Stub.Authors; + return await OrderAuthors(authors, index, count, sort); + } + + public async Task>> GetAuthorsByName(string name, int index, int count, string sort = "") + { + var authors = Stub.Authors.Where(a => a.Name.Contains(name, StringComparison.OrdinalIgnoreCase) + || a.AlternateNames.Exists(alt => alt.Contains(name, StringComparison.OrdinalIgnoreCase))); + return await OrderAuthors(authors, index, count, sort); + } + + public Task GetBookById(string id) + { + var book = Stub.Books.SingleOrDefault(b => b.Id.Contains(id)); + return Task.FromResult(book); + } + + private Task>> OrderBooks(IEnumerable books, int index, int count, string sort = "") + { + switch(sort) + { + case "title": + books = books.OrderBy(b => b.Title); + break; + case "title_reverse": + books = books.OrderByDescending(b => b.Title); + break; + case "new": + books = books.OrderByDescending(b => b.PublishDate); + break; + case "old": + books = books.OrderBy(b => b.PublishDate); + break; + + } + return Task.FromResult(Tuple.Create((long)books.Count(), books.Skip(index*count).Take(count))); + } + + public async Task>> GetBooks(int index, int count, string sort = "") + { + var books = Stub.Books; + return await OrderBooks(books, index, count, sort); + } + + public Task GetBookByISBN(string isbn) + { + var book = Stub.Books.SingleOrDefault(b => b.ISBN13.Equals(isbn, StringComparison.OrdinalIgnoreCase)); + return Task.FromResult(book); + } + + public async Task>> GetBooksByTitle(string title, int index, int count, string sort = "") + { + var books = Stub.Books.Where(b => b.Title.Contains(title, StringComparison.OrdinalIgnoreCase) + || b.Series.Exists(s => s.Contains(title, StringComparison.OrdinalIgnoreCase))); + return await OrderBooks(books, index, count, sort); + } + + public async Task>> GetBooksByAuthorId(string authorId, int index, int count, string sort = "") + { + var books = Stub.Books.Where(b => b.Authors.Exists(a => a.Id.Contains(authorId)) + || b.Works.Exists(w => w.Authors.Exists(a => a.Id.Contains(authorId)))); + return await OrderBooks(books, index, count, sort); + } + + public async Task>> GetBooksByAuthor(string name, int index, int count, string sort = "") + { + var books = Stub.Books.Where(b => ContainsAuthorName(b, name)); + return await OrderBooks(books, index, count, sort); + } + + private bool ContainsAuthorName(BookDTO book, string name) + { + IEnumerable authors = new List(); + + if(book.Authors != null && book.Authors.Count > 0) + { + authors = authors.Union(book.Authors); + } + if(book.Works != null) + { + var worksAuthors = book.Works.SelectMany(w => w.Authors).ToList(); + if(worksAuthors.Count > 0) + authors = authors.Union(worksAuthors); + } + foreach(var author in authors) + { + if(author.Name.Contains(name, StringComparison.OrdinalIgnoreCase) + || author.AlternateNames.Exists(alt => alt.Contains(name, StringComparison.OrdinalIgnoreCase))) + { + return true; + } + } + return false; + } + + public Task>> GetWorks(int index, int count) + { + long nbWorks = Stub.Works.Count; + var works = Stub.Works.Skip(index*count).Take(count); + return Task.FromResult(Tuple.Create(nbWorks, works)); + } + + public Task GetNbAuthors() + => Task.FromResult((long)Stub.Authors.Count); + + public Task GetNbBooks() + => Task.FromResult((long)Stub.Books.Count); + + public Task GetNbWorks() + => Task.FromResult((long)Stub.Works.Count); +} + diff --git a/Sources/StubbedDTO/StubbedDTO.csproj b/Sources/StubbedDTO/StubbedDTO.csproj new file mode 100644 index 0000000..70ef770 --- /dev/null +++ b/Sources/StubbedDTO/StubbedDTO.csproj @@ -0,0 +1,32 @@ + + + + net7.0 + enable + enable + + + + + + + + + + + + + + + + + PreserveNewest + PreserveNewest + + + + + + + + diff --git a/Sources/StubbedDTO/authors/OL1846639A.json b/Sources/StubbedDTO/authors/OL1846639A.json new file mode 100644 index 0000000..4b82846 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL1846639A.json @@ -0,0 +1,12 @@ +{ + "name": "Michel Demuth", + "personal_name": "Michel Demuth", + "last_modified": { + "type": "/type/datetime", + "value": "2008-08-26 02:41:15.604911" + }, + "key": "/authors/OL1846639A", + "type": { "key": "/type/author" }, + "id": 6527877, + "revision": 2 +} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL274606A.json b/Sources/StubbedDTO/authors/OL274606A.json new file mode 100644 index 0000000..0718f7b --- /dev/null +++ b/Sources/StubbedDTO/authors/OL274606A.json @@ -0,0 +1,34 @@ +{ + "personal_name": "Dick, Philip K.", + "source_records": [ "amazon:8445007327", "bwb:9780722129562", "amazon:0792776232", "ia:pacificpark0000dick", "amazon:2277213799", "amazon:2266163019", "bwb:9798599263227", "amazon:1433276712", "ia:ejonescreoilmond0000dick", "amazon:6051719164", "amazon:6254493632", "amazon:2277117749", "amazon:1987781619", "amazon:1433248239", "amazon:1480594407" ], + "alternate_names": [ "Philip Kindred Dick", "Philip Dick", "Philip Kendred Dick", "Philip K Dick" ], + "bio": "Philip Kindred Dick was an American novelist, short story writer, and essayist whose published work during his lifetime was almost entirely in the science fiction genre. Dick explored sociological, political and metaphysical themes in novels dominated by monopolistic corporations, authoritarian governments, and altered states. In his later works, Dick's thematic focus strongly reflected his personal interest in metaphysics and theology. He often drew upon his own life experiences and addressed the nature of drug abuse, paranoia and schizophrenia, and transcendental experiences in novels such as A Scanner Darkly and VALIS.\r\n\r\nSource and more information: [Wikipedia (EN)](http://en.wikipedia.org/wiki/Philip_K._Dick)", + "type": { "key": "/type/author" }, + "death_date": "2 March 1982", + "remote_ids": { + "isni": "0000000121251093", + "wikidata": "Q171091", + "viaf": "27063583" + }, + "name": "Philip K. Dick", + "links": [ + { + "title": "Wikipedia link to Philip K Dick", + "url": "http://en.wikipedia.org/wiki/Philip_K._Dick", + "type": { "key": "/type/link" } + } + ], + "photos": [ 6295259 ], + "birth_date": "16 December 1928", + "key": "/authors/OL274606A", + "latest_revision": 23, + "revision": 23, + "created": { + "type": "/type/datetime", + "value": "2008-04-01T03:28:50.625462" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2022-11-29T21:21:41.951561" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL3113900A.json b/Sources/StubbedDTO/authors/OL3113900A.json new file mode 100644 index 0000000..1aa9add --- /dev/null +++ b/Sources/StubbedDTO/authors/OL3113900A.json @@ -0,0 +1 @@ +{"name": "Gilles Goullet", "last_modified": {"type": "/type/datetime", "value": "2008-04-30 08:14:56.482104"}, "key": "/authors/OL3113900A", "type": {"key": "/type/author"}, "id": 11970651, "revision": 1} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL3113922A.json b/Sources/StubbedDTO/authors/OL3113922A.json new file mode 100644 index 0000000..63fe25b --- /dev/null +++ b/Sources/StubbedDTO/authors/OL3113922A.json @@ -0,0 +1,11 @@ +{ + "name": "H\u00e9l\u00e8ne Collon", + "last_modified": { + "type": "/type/datetime", + "value": "2008-04-30 08:14:56.482104" + }, + "key": "/authors/OL3113922A", + "type": { "key": "/type/author" }, + "id": 11970257, + "revision": 1 +} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL3980331A.json b/Sources/StubbedDTO/authors/OL3980331A.json new file mode 100644 index 0000000..17a6d32 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL3980331A.json @@ -0,0 +1,17 @@ +{ + "name": "Alain Damasio", + "key": "/authors/OL3980331A", + "type": { "key": "/type/author" }, + "remote_ids": { "wikidata": "Q2829704" }, + "birth_date": "1 August 1969", + "latest_revision": 2, + "revision": 2, + "created": { + "type": "/type/datetime", + "value": "2008-04-30T20:50:18.033121" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2022-12-19T19:05:32.693708" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL6982995A.json b/Sources/StubbedDTO/authors/OL6982995A.json new file mode 100644 index 0000000..51ccd1e --- /dev/null +++ b/Sources/StubbedDTO/authors/OL6982995A.json @@ -0,0 +1,36 @@ +{ + "personal_name": "James S. A. Corey", + "remote_ids": { + "isni": "0000000382626033", + "viaf": "266413968", + "wikidata": "Q6142591" + }, + "source_records": [ "amazon:1478933771", "amazon:1528822218", "amazon:1456121650", "bwb:9780356510385", "amazon:0678452547", "bwb:9780356517773" ], + "alternate_names": [ "Daniel Abraham", "Ty Franck", "James S.A. Corey", "James James S. A. Corey" ], + "type": { "key": "/type/author" }, + "key": "/authors/OL6982995A", + "entity_type": "org", + "links": [ + { + "title": "Source", + "url": "http://www.danielabraham.com/james-s-a-corey/", + "type": { "key": "/type/link" } + } + ], + "bio": { + "type": "/type/text", + "value": "James S.A. Corey is the pen name used by collaborators [Daniel Abraham](https://openlibrary.org/authors/OL1427729A/Daniel_Abraham) and [Ty Franck](https://openlibrary.org/authors/OL7523472A/Ty_Franck).\r\n\r\nThe first and last name are taken from Abraham's and Franck's middle names, respectively, and S.A. are the initials of Abraham's daughter." + }, + "photos": [ 11112303 ], + "name": "James S. A. Corey", + "latest_revision": 13, + "revision": 13, + "created": { + "type": "/type/datetime", + "value": "2011-10-20T08:06:05.906616" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2023-05-18T18:14:26.659278" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL7475792A.json b/Sources/StubbedDTO/authors/OL7475792A.json new file mode 100644 index 0000000..777b623 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL7475792A.json @@ -0,0 +1,15 @@ +{ + "key": "/authors/OL7475792A", + "name": "Ada Palmer", + "type": { "key": "/type/author" }, + "latest_revision": 4, + "revision": 4, + "created": { + "type": "/type/datetime", + "value": "2019-03-11T19:38:25.579004" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2021-12-07T07:11:29.213401" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL7876839A.json b/Sources/StubbedDTO/authors/OL7876839A.json new file mode 100644 index 0000000..15d1ff6 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL7876839A.json @@ -0,0 +1 @@ +{"name": "Robert Charles Wilson", "created": {"type": "/type/datetime", "value": "2020-05-08T21:00:30.785249"}, "last_modified": {"type": "/type/datetime", "value": "2020-05-08T21:00:30.785249"}, "latest_revision": 1, "key": "/authors/OL7876839A", "type": {"key": "/type/author"}, "revision": 1} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL79034A.json b/Sources/StubbedDTO/authors/OL79034A.json new file mode 100644 index 0000000..ce17b23 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL79034A.json @@ -0,0 +1,42 @@ +{ + "remote_ids": { + "viaf": "59083797", + "wikidata": "Q7934", + "isni": "0000000121347853" + }, + "name": "Frank Herbert", + "source_records": [ "amazon:3870703903", "amazon:2253113190", "amazon:1427228493" ], + "alternate_names": [ "Herbert, Frank", "FRANK HERBERT", "Frank HERBERT", "herbert-frank", "frank herbert", "Herbert Frank", "Frank Herbert Dost Korpe", "HERBERT FRANK", "Franck Herbert", "F Herbert" ], + "photos": [ 12194537, 7277115, 10643754 ], + "links": [ + { + "url": "http://en.wikipedia.org/wiki/Frank_Herbert", + "type": { "key": "/type/link" }, + "title": "Wikipedia English" + }, + { + "url": "http://fr.wikipedia.org/wiki/Frank_Herbert", + "type": { "key": "/type/link" }, + "title": "Wikipedia France" + } + ], + "key": "/authors/OL79034A", + "birth_date": "8 October 1920", + "death_date": "11 February 1986", + "type": { "key": "/type/author" }, + "personal_name": "Herbert, Frank.", + "bio": { + "type": "/type/text", + "value": "Real name: Franklin Patrick Herbert Jr." + }, + "latest_revision": 15, + "revision": 15, + "created": { + "type": "/type/datetime", + "value": "2008-04-01T03:28:50.625462" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2021-11-12T11:41:55.357817" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL9956442A.json b/Sources/StubbedDTO/authors/OL9956442A.json new file mode 100644 index 0000000..3b660a9 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL9956442A.json @@ -0,0 +1,16 @@ +{ + "type": { "key": "/type/author" }, + "name": "Frank Herbert", + "key": "/authors/OL9956442A", + "source_records": [ "amazon:2221252306" ], + "latest_revision": 1, + "revision": 1, + "created": { + "type": "/type/datetime", + "value": "2021-11-14T17:07:35.515652" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2021-11-14T17:07:35.515652" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL25910297M.json b/Sources/StubbedDTO/books/OL25910297M.json new file mode 100644 index 0000000..b94543f --- /dev/null +++ b/Sources/StubbedDTO/books/OL25910297M.json @@ -0,0 +1,24 @@ +{ + "publishers": [ "Actes Sud" ], + "title": "L'\u00c9veil du L\u00e9viathan", + "number_of_pages": 624, + "isbn_13": [ "9782330033118" ], + "covers": [ 7412481 ], + "languages": [ { "key": "/languages/fre" } ], + "publish_date": "4 juin 2014", + "key": "/books/OL25910297M", + "publish_places": [ "France" ], + "works": [ { "key": "/works/OL17334140W" } ], + "type": { "key": "/type/edition" }, + "source_records": [ "amazon:2330033117" ], + "latest_revision": 5, + "revision": 5, + "created": { + "type": "/type/datetime", + "value": "2016-04-22T11:47:01.838591" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2023-02-02T01:19:11.921173" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL27258011M.json b/Sources/StubbedDTO/books/OL27258011M.json new file mode 100644 index 0000000..384aa86 --- /dev/null +++ b/Sources/StubbedDTO/books/OL27258011M.json @@ -0,0 +1,23 @@ +{ + "publishers": [ "Editions Gallimard" ], + "source_records": [ "amazon:2070793109" ], + "title": "La m\u00e9nagerie de papier", + "identifiers": { "amazon": [ "2070793109" ] }, + "isbn_13": [ "9782070793105" ], + "covers": [ 8750266 ], + "created": { + "type": "/type/datetime", + "value": "2019-08-05T10:36:44.503432" + }, + "physical_format": "mass market paperback", + "isbn_10": [ "2070793109" ], + "latest_revision": 1, + "key": "/books/OL27258011M", + "last_modified": { + "type": "/type/datetime", + "value": "2019-08-05T10:36:44.503432" + }, + "works": [ { "key": "/works/OL20078005W" } ], + "type": { "key": "/type/edition" }, + "revision": 1 +} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL27989051M.json b/Sources/StubbedDTO/books/OL27989051M.json new file mode 100644 index 0000000..878d598 --- /dev/null +++ b/Sources/StubbedDTO/books/OL27989051M.json @@ -0,0 +1,38 @@ +{ + "publishers": [ "Le B\u00e9lial'" ], + "subtitle": "Terra Ignota volume 2", + "covers": [ 9376451 ], + "physical_format": "paperback", + "full_title": "Sept redditions : Terra Ignota volume 2", + "key": "/books/OL27989051M", + "authors": [ { "key": "/authors/OL7475792A" } ], + "source_records": [ "amazon:2843449626" ], + "title": "Sept redditions", + "notes": "Source title: Sept redditions: Terra Ignota volume 2 (Roman)", + "number_of_pages": 544, + "publish_date": "May 28, 2020", + "works": [ { "key": "/works/OL19213555W" } ], + "type": { "key": "/type/edition" }, + "identifiers": {}, + "isbn_10": [ "2843449626" ], + "isbn_13": [ "9782843449628" ], + "classifications": {}, + "languages": [ { "key": "/languages/fre" } ], + "contributors": [ + { + "name": "Michelle Charrier", + "role": "Translator" + } + ], + "series": [ "Terra Ignota #2" ], + "latest_revision": 4, + "revision": 4, + "created": { + "type": "/type/datetime", + "value": "2020-05-02T22:25:18.922926" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2021-12-07T07:10:56.070304" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL28294024M.json b/Sources/StubbedDTO/books/OL28294024M.json new file mode 100644 index 0000000..e5c5dcf --- /dev/null +++ b/Sources/StubbedDTO/books/OL28294024M.json @@ -0,0 +1 @@ +{"publishers": ["GALLIMARD"], "last_modified": {"type": "/type/datetime", "value": "2020-06-28T05:17:49.626242"}, "source_records": ["amazon:2070469875"], "title": "La trilogie Spin", "notes": {"type": "/type/text", "value": "Source title: La trilogie Spin (Folio SF - XL) (French Edition)"}, "number_of_pages": 1120, "isbn_13": ["9782070469871"], "covers": [10218906], "created": {"type": "/type/datetime", "value": "2020-06-28T05:17:49.626242"}, "physical_format": "paperback", "isbn_10": ["2070469875"], "publish_date": "Jun 02, 2016", "key": "/books/OL28294024M", "authors": [{"key": "/authors/OL7876839A"}, {"key": "/authors/OL3113900A"}], "latest_revision": 1, "works": [{"key": "/works/OL20889233W"}], "type": {"key": "/type/edition"}, "revision": 1} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL28639494M.json b/Sources/StubbedDTO/books/OL28639494M.json new file mode 100644 index 0000000..f5d7575 --- /dev/null +++ b/Sources/StubbedDTO/books/OL28639494M.json @@ -0,0 +1,32 @@ +{ + "publishers": [ "Pocket", "POCKET" ], + "source_records": [ "amazon:2266235818" ], + "title": "Le Cycle de Dune Tome 2/Le Messie de Dune", + "notes": { + "type": "/type/text", + "value": "Source title: Le Cycle de Dune Tome 2/Le Messie de Dune (Science-fiction) (French Edition)" + }, + "number_of_pages": 336, + "isbn_13": [ "9782266235815" ], + "covers": [ 10328275 ], + "physical_format": "mass market paperback", + "isbn_10": [ "2266235818" ], + "publish_date": "Nov 22, 2012", + "key": "/books/OL28639494M", + "authors": [ + { "key": "/authors/OL79034A" }, + { "key": "/authors/OL1846639A" } + ], + "works": [ { "key": "/works/OL893526W" } ], + "type": { "key": "/type/edition" }, + "latest_revision": 3, + "revision": 3, + "created": { + "type": "/type/datetime", + "value": "2020-08-05T18:59:33.402965" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2021-10-24T22:27:33.839388" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL35698073M.json b/Sources/StubbedDTO/books/OL35698073M.json new file mode 100644 index 0000000..b6a949a --- /dev/null +++ b/Sources/StubbedDTO/books/OL35698073M.json @@ -0,0 +1,31 @@ +{ + "identifiers": { "wikidata": [ "Q81118625" ] }, + "title": "Trop semblable \u00e0 l'\u00e9clair", + "publish_date": "2019", + "publishers": [ "Le B\u00e9lial'" ], + "type": { "key": "/type/edition" }, + "isbn_13": [ "9782843449581" ], + "series": [ "Terra Ignota #1" ], + "physical_format": "paperback", + "contributors": [ + { + "name": "Michelle Charrier", + "role": "Translator" + } + ], + "languages": [ { "key": "/languages/fre" } ], + "key": "/books/OL35698073M", + "number_of_pages": 672, + "works": [ { "key": "/works/OL19800093W" } ], + "source_records": [ "amazon:2843449588" ], + "latest_revision": 4, + "revision": 4, + "created": { + "type": "/type/datetime", + "value": "2021-12-07T02:12:00.907076" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2022-11-15T15:47:17.497202" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL35698083M.json b/Sources/StubbedDTO/books/OL35698083M.json new file mode 100644 index 0000000..006a950 --- /dev/null +++ b/Sources/StubbedDTO/books/OL35698083M.json @@ -0,0 +1,32 @@ +{ + "works": [ { "key": "/works/OL19635836W" } ], + "title": "La Volont\u00e9 de se battre", + "publishers": [ "Le B\u00e9lial'" ], + "publish_date": "2020", + "key": "/books/OL35698083M", + "type": { "key": "/type/edition" }, + "identifiers": {}, + "covers": [ 12392970 ], + "isbn_13": [ "9782843449758" ], + "classifications": {}, + "languages": [ { "key": "/languages/fre" } ], + "contributors": [ + { + "name": "Michelle Charrier", + "role": "Translator" + } + ], + "number_of_pages": 526, + "series": [ "Terra Ignota #3" ], + "physical_format": "paperback", + "latest_revision": 3, + "revision": 3, + "created": { + "type": "/type/datetime", + "value": "2021-12-07T02:23:07.593997" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2021-12-07T02:24:57.135563" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL35699439M.json b/Sources/StubbedDTO/books/OL35699439M.json new file mode 100644 index 0000000..62610a7 --- /dev/null +++ b/Sources/StubbedDTO/books/OL35699439M.json @@ -0,0 +1,26 @@ +{ + "type": { "key": "/type/edition" }, + "title": "La Zone du Dehors", + "authors": [ { "key": "/authors/OL3980331A" } ], + "publish_date": "Feb 04, 2021", + "source_records": [ "amazon:2072927528" ], + "number_of_pages": 656, + "publishers": [ "FOLIO", "GALLIMARD" ], + "isbn_10": [ "2072927528" ], + "isbn_13": [ "9782072927522" ], + "physical_format": "pocket book", + "full_title": "La Zone du Dehors", + "covers": [ 12393645 ], + "works": [ { "key": "/works/OL19960903W" } ], + "key": "/books/OL35699439M", + "latest_revision": 1, + "revision": 1, + "created": { + "type": "/type/datetime", + "value": "2021-12-07T22:26:13.534930" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2021-12-07T22:26:13.534930" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL38218739M.json b/Sources/StubbedDTO/books/OL38218739M.json new file mode 100644 index 0000000..43e3f46 --- /dev/null +++ b/Sources/StubbedDTO/books/OL38218739M.json @@ -0,0 +1,31 @@ +{ + "type": { "key": "/type/edition" }, + "title": "Dune - tome 1", + "authors": [ + { "key": "/authors/OL9956442A" }, + { "key": "/authors/OL1846639A" } + ], + "publish_date": "Nov 22, 2012", + "source_records": [ "amazon:2266233203" ], + "number_of_pages": 832, + "publishers": [ "POCKET", "Pocket" ], + "isbn_10": [ "2266233203" ], + "isbn_13": [ "9782266233200" ], + "physical_format": "pocket book", + "notes": { + "type": "/type/text", + "value": "Source title: Dune - tome 1 (1)" + }, + "works": [ { "key": "/works/OL27962193W" } ], + "key": "/books/OL38218739M", + "latest_revision": 1, + "revision": 1, + "created": { + "type": "/type/datetime", + "value": "2022-05-30T17:18:00.228322" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2022-05-30T17:18:00.228322" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL38586212M.json b/Sources/StubbedDTO/books/OL38586212M.json new file mode 100644 index 0000000..1ab8986 --- /dev/null +++ b/Sources/StubbedDTO/books/OL38586212M.json @@ -0,0 +1,28 @@ +{ + "type": { "key": "/type/edition" }, + "title": "Total Recall et autres r\u00e9cits", + "authors": [ + { "key": "/authors/OL274606A" }, + { "key": "/authors/OL3113922A" } + ], + "publish_date": "Jul 12, 2012", + "source_records": [ "amazon:2070448908" ], + "number_of_pages": 448, + "publishers": [ "FOLIO", "GALLIMARD" ], + "isbn_10": [ "2070448908" ], + "isbn_13": [ "9782070448906" ], + "physical_format": "pocket book", + "works": [ { "key": "/works/OL28185064W" } ], + "key": "/books/OL38586212M", + "covers": [ 13858141 ], + "latest_revision": 3, + "revision": 3, + "created": { + "type": "/type/datetime", + "value": "2022-07-10T01:29:29.296699" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2023-04-07T22:44:13.567567" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL17334140W.ratings.json b/Sources/StubbedDTO/ratings/OL17334140W.ratings.json new file mode 100644 index 0000000..536dae4 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL17334140W.ratings.json @@ -0,0 +1,13 @@ +{ + "summary": { + "average": null, + "count": 0 + }, + "counts": { + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0 + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL19213555W.ratings.json b/Sources/StubbedDTO/ratings/OL19213555W.ratings.json new file mode 100644 index 0000000..3cc42e0 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL19213555W.ratings.json @@ -0,0 +1 @@ +{"summary": {"average": 4.333333333333333, "count": 6, "sortable": 3.114900291576932}, "counts": {"1": 0, "2": 0, "3": 1, "4": 2, "5": 3}} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL19635836W.ratings.json b/Sources/StubbedDTO/ratings/OL19635836W.ratings.json new file mode 100644 index 0000000..202f4ac --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL19635836W.ratings.json @@ -0,0 +1,14 @@ +{ + "summary": { + "average": 4.8, + "count": 5, + "sortable": 3.216059213089321 + }, + "counts": { + "1": 0, + "2": 0, + "3": 0, + "4": 1, + "5": 4 + } +} diff --git a/Sources/StubbedDTO/ratings/OL19800093W.ratings.json b/Sources/StubbedDTO/ratings/OL19800093W.ratings.json new file mode 100644 index 0000000..0f30a8c --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL19800093W.ratings.json @@ -0,0 +1 @@ +{"summary": {"average": 3.6923076923076925, "count": 13, "sortable": 2.9048164811987554}, "counts": {"1": 2, "2": 2, "3": 1, "4": 1, "5": 7}} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL19960903W.ratings.json b/Sources/StubbedDTO/ratings/OL19960903W.ratings.json new file mode 100644 index 0000000..14c4ff0 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL19960903W.ratings.json @@ -0,0 +1,14 @@ +{ + "summary": { + "average": 4.0, + "count": 1, + "sortable": 2.3286737413641063 + }, + "counts": { + "1": 0, + "2": 0, + "3": 0, + "4": 1, + "5": 0 + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL20078005W.ratings.json b/Sources/StubbedDTO/ratings/OL20078005W.ratings.json new file mode 100644 index 0000000..85e13a6 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL20078005W.ratings.json @@ -0,0 +1 @@ +{"summary": {"average": null, "count": 0}, "counts": {"1": 0, "2": 0, "3": 0, "4": 0, "5": 0}} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL20889233W.ratings.json b/Sources/StubbedDTO/ratings/OL20889233W.ratings.json new file mode 100644 index 0000000..85e13a6 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL20889233W.ratings.json @@ -0,0 +1 @@ +{"summary": {"average": null, "count": 0}, "counts": {"1": 0, "2": 0, "3": 0, "4": 0, "5": 0}} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL27962193W.ratings.json b/Sources/StubbedDTO/ratings/OL27962193W.ratings.json new file mode 100644 index 0000000..9accbc5 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL27962193W.ratings.json @@ -0,0 +1,14 @@ +{ + "summary": { + "average": 3.0, + "count": 1, + "sortable": 2.19488243981746 + }, + "counts": { + "1": 0, + "2": 0, + "3": 1, + "4": 0, + "5": 0 + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL28185064W.ratings.json b/Sources/StubbedDTO/ratings/OL28185064W.ratings.json new file mode 100644 index 0000000..536dae4 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL28185064W.ratings.json @@ -0,0 +1,13 @@ +{ + "summary": { + "average": null, + "count": 0 + }, + "counts": { + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0 + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL893526W.ratings.json b/Sources/StubbedDTO/ratings/OL893526W.ratings.json new file mode 100644 index 0000000..8b4cddd --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL893526W.ratings.json @@ -0,0 +1 @@ +{"summary": {"average": 3.9368421052631577, "count": 95, "sortable": 3.721132697535656}, "counts": {"1": 3, "2": 4, "3": 19, "4": 39, "5": 30}} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL17334140W.json b/Sources/StubbedDTO/works/OL17334140W.json new file mode 100644 index 0000000..839a824 --- /dev/null +++ b/Sources/StubbedDTO/works/OL17334140W.json @@ -0,0 +1,22 @@ +{ + "title": "L'\u00c9veil du L\u00e9viathan", + "key": "/works/OL17334140W", + "authors": [ + { + "type": { "key": "/type/author_role" }, + "author": { "key": "/authors/OL6982995A" } + } + ], + "type": { "key": "/type/work" }, + "covers": [ 7412481 ], + "latest_revision": 3, + "revision": 3, + "created": { + "type": "/type/datetime", + "value": "2016-04-22T11:47:01.838591" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2023-02-02T01:19:11.921173" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL19213555W.json b/Sources/StubbedDTO/works/OL19213555W.json new file mode 100644 index 0000000..a758427 --- /dev/null +++ b/Sources/StubbedDTO/works/OL19213555W.json @@ -0,0 +1 @@ +{"description": "\"It is a world in which near-instantaneous travel from continent to continent is free to all. In which automation now provides for everybody's basic needs. In which nobody living can remember an actual war. In which it is illegal for three or more people to gather for the practice of religion--but ecumenical \"sensayers\" minister in private, one-on-one. In which gendered language is archaic, and to dress as strongly male or female is, if not exactly illegal, deeply taboo. In which nationality is a fading memory, and most people identify instead with their choice of the seven global Hives, distinguished from one another by their different approaches to the big questions of life. And it is a world in which, unknown to most, the entire social order is teetering on the edge of collapse. Because even in utopia, humans will conspire. And also because something new has arisen: Bridger, the child who can bring inanimate objects to conscious life\"--", "covers": [8429595, 8772829, 9338105, 9376451], "key": "/works/OL19213555W", "authors": [{"author": {"key": "/authors/OL7475792A"}, "type": {"key": "/type/author_role"}}], "title": "Seven Surrenders", "subjects": ["Utopias", "Fiction", "Fiction, science fiction, general", "series:terra_ignota"], "type": {"key": "/type/work"}, "latest_revision": 6, "revision": 6, "created": {"type": "/type/datetime", "value": "2019-03-11T19:38:25.579004"}, "last_modified": {"type": "/type/datetime", "value": "2021-12-07T07:10:56.070304"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL19635836W.json b/Sources/StubbedDTO/works/OL19635836W.json new file mode 100644 index 0000000..6d7f024 --- /dev/null +++ b/Sources/StubbedDTO/works/OL19635836W.json @@ -0,0 +1,24 @@ +{ + "description": "\"The long years of near-utopia have come to an abrupt end. Peace and order are now figments of the past. Corruption, deception, and insurgency hum within the once steadfast leadership of the Hives, nations without fixed location. The heartbreaking truth is that for decades, even centuries, the leaders of the great Hives bought the world's stability with a trickle of secret murders, mathematically planned. So that no faction could ever dominate. So that the balance held. The Hives' fa\u00e7ade of solidity is the only hope they have for maintaining a semblance of order, for preventing the public from succumbing to the savagery and bloodlust of wars past. But as the great secret becomes more and more widely known, that fa\u00e7ade is slipping away. Just days earlier, the world was a pinnacle of human civilization. Now everyone--Hives and hiveless, Utopians and sensayers, emperors and the downtrodden, warriors and saints--scrambles to prepare for the seemingly inevitable war\"--", + "covers": [ 8544084, 8619055, 10180814 ], + "key": "/works/OL19635836W", + "authors": [ + { + "author": { "key": "/authors/OL7475792A" }, + "type": { "key": "/type/author_role" } + } + ], + "title": "The Will to Battle", + "subjects": [ "Utopias", "Fiction", "Fiction, science fiction, general", "series:terra_ignota" ], + "type": { "key": "/type/work" }, + "latest_revision": 7, + "revision": 7, + "created": { + "type": "/type/datetime", + "value": "2019-04-21T08:07:12.674468" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2021-12-07T07:08:28.885088" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL19800093W.json b/Sources/StubbedDTO/works/OL19800093W.json new file mode 100644 index 0000000..8d9df69 --- /dev/null +++ b/Sources/StubbedDTO/works/OL19800093W.json @@ -0,0 +1 @@ +{"description": "\"The world into which Mycroft and Carlyle have been born is as strange to our 21st-century eyes as ours would be to a native of the 1500s. It is a hard-won utopia built on technologically-generated abundance, and also on complex and mandatory systems of labeling all public writing and speech... And in this world, Mycroft and Carlyle have stumbled on the wild card that may destabilize the system: the boy Bridger, who can effortlessly make his wishes come true. Who can, it would seem, bring inanimate objects to life...\"--Book jacket.", "covers": [8600692, 8673756], "key": "/works/OL19800093W", "authors": [{"author": {"key": "/authors/OL7475792A"}, "type": {"key": "/type/author_role"}}], "title": "Too Like the Lightning", "subjects": ["Utopias", "Prisoners", "Twenty-fifth century", "Fiction", "Third millennium", "Fiction, science fiction, general", "series:terra_ignota", "Spirituality", "Magic", "FICTION", "Science Fiction"], "type": {"key": "/type/work"}, "latest_revision": 6, "revision": 6, "created": {"type": "/type/datetime", "value": "2019-06-23T20:50:30.749828"}, "last_modified": {"type": "/type/datetime", "value": "2022-03-12T06:35:56.153258"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL19960903W.json b/Sources/StubbedDTO/works/OL19960903W.json new file mode 100644 index 0000000..ba6654e --- /dev/null +++ b/Sources/StubbedDTO/works/OL19960903W.json @@ -0,0 +1,22 @@ +{ + "title": "La zone du dehors", + "key": "/works/OL19960903W", + "authors": [ + { + "type": { "key": "/type/author_role" }, + "author": { "key": "/authors/OL3980331A" } + } + ], + "type": { "key": "/type/work" }, + "covers": [ 13472433 ], + "latest_revision": 2, + "revision": 2, + "created": { + "type": "/type/datetime", + "value": "2019-07-17T23:01:16.580404" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2023-03-15T21:59:10.897047" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL20078005W.json b/Sources/StubbedDTO/works/OL20078005W.json new file mode 100644 index 0000000..bb2c7ec --- /dev/null +++ b/Sources/StubbedDTO/works/OL20078005W.json @@ -0,0 +1,16 @@ +{ + "title": "La m\u00e9nagerie de papier", + "created": { + "type": "/type/datetime", + "value": "2019-08-05T10:36:44.503432" + }, + "covers": [ 8750266 ], + "last_modified": { + "type": "/type/datetime", + "value": "2019-08-05T10:36:44.503432" + }, + "latest_revision": 1, + "key": "/works/OL20078005W", + "type": { "key": "/type/work" }, + "revision": 1 +} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL20889233W.json b/Sources/StubbedDTO/works/OL20889233W.json new file mode 100644 index 0000000..11b0d93 --- /dev/null +++ b/Sources/StubbedDTO/works/OL20889233W.json @@ -0,0 +1 @@ +{"title": "La trilogie Spin", "created": {"type": "/type/datetime", "value": "2020-06-28T05:17:49.626242"}, "covers": [10218906], "last_modified": {"type": "/type/datetime", "value": "2020-06-28T05:17:49.626242"}, "latest_revision": 1, "key": "/works/OL20889233W", "authors": [{"type": {"key": "/type/author_role"}, "author": {"key": "/authors/OL7876839A"}}, {"type": {"key": "/type/author_role"}, "author": {"key": "/authors/OL3113900A"}}], "type": {"key": "/type/work"}, "revision": 1} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL27962193W.json b/Sources/StubbedDTO/works/OL27962193W.json new file mode 100644 index 0000000..4eefdac --- /dev/null +++ b/Sources/StubbedDTO/works/OL27962193W.json @@ -0,0 +1,26 @@ +{ + "type": { "key": "/type/work" }, + "title": "Dune - tome 1", + "authors": [ + { + "type": { "key": "/type/author_role" }, + "author": { "key": "/authors/OL9956442A" } + }, + { + "type": { "key": "/type/author_role" }, + "author": { "key": "/authors/OL1846639A" } + } + ], + "key": "/works/OL27962193W", + "covers": [ 13823878 ], + "latest_revision": 2, + "revision": 2, + "created": { + "type": "/type/datetime", + "value": "2022-05-30T17:18:00.228322" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2023-04-04T09:05:11.531979" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL28185064W.json b/Sources/StubbedDTO/works/OL28185064W.json new file mode 100644 index 0000000..9a83844 --- /dev/null +++ b/Sources/StubbedDTO/works/OL28185064W.json @@ -0,0 +1,26 @@ +{ + "type": { "key": "/type/work" }, + "title": "Total Recall et autres r\u00e9cits", + "authors": [ + { + "type": { "key": "/type/author_role" }, + "author": { "key": "/authors/OL274606A" } + }, + { + "type": { "key": "/type/author_role" }, + "author": { "key": "/authors/OL3113922A" } + } + ], + "key": "/works/OL28185064W", + "covers": [ 13858141 ], + "latest_revision": 3, + "revision": 3, + "created": { + "type": "/type/datetime", + "value": "2022-07-10T01:29:29.296699" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2023-04-07T22:44:13.567567" + } +} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL893526W.json b/Sources/StubbedDTO/works/OL893526W.json new file mode 100644 index 0000000..835d810 --- /dev/null +++ b/Sources/StubbedDTO/works/OL893526W.json @@ -0,0 +1 @@ +{"subjects": ["American Science fiction", "Dune (Imaginary place)", "Fiction", "Fiction in English", "Imaginary places", "Science Fiction", "Translations into Russian", "Novela", "Dune (Lugar imaginario)", "Lectures et morceaux choisis", "Anglais (langue)", "Roman ame ricain", "Science-fiction ame ricaine", "Long Now Manual for Civilization", "Roman ame\u0301ricain", "Science-fiction ame\u0301ricaine", "Dune (imaginary place), fiction", "Fiction, science fiction, general"], "key": "/works/OL893526W", "title": "Dune Messiah", "authors": [{"author": {"key": "/authors/OL79034A"}, "type": {"key": "/type/author_role"}}, {"author": {"key": "/authors/OL1846639A"}, "type": {"key": "/type/author_role"}}], "type": {"key": "/type/work"}, "covers": [2421405, 1009421, 5277575, 284503, 8450071, 8771464, 10328275, 11422534, 11290920, 10849793, 979507, 8376882], "description": {"type": "/type/text", "value": "Bearbeitete Neuausgabe"}, "latest_revision": 18, "revision": 18, "created": {"type": "/type/datetime", "value": "2009-12-09T06:52:50.872607"}, "last_modified": {"type": "/type/datetime", "value": "2023-01-31T17:11:49.536060"}} \ No newline at end of file diff --git a/Sources/TestFrontEnd/GlobalUsings.cs b/Sources/Tests/GlobalUsings.cs similarity index 100% rename from Sources/TestFrontEnd/GlobalUsings.cs rename to Sources/Tests/GlobalUsings.cs diff --git a/Sources/TestFrontEnd/TestFrontEnd.csproj b/Sources/Tests/TestFrontEnd.csproj similarity index 100% rename from Sources/TestFrontEnd/TestFrontEnd.csproj rename to Sources/Tests/TestFrontEnd.csproj diff --git a/Sources/TestFrontEnd/UnitTest1.cs b/Sources/Tests/UnitTest1.cs similarity index 100% rename from Sources/TestFrontEnd/UnitTest1.cs rename to Sources/Tests/UnitTest1.cs diff --git a/Sources/Utils/EnumsMapper.cs b/Sources/Utils/EnumsMapper.cs new file mode 100644 index 0000000..5b4f8eb --- /dev/null +++ b/Sources/Utils/EnumsMapper.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Utils +{ + public class EnumsMapper where T : Enum + where U : Enum + { + readonly HashSet> mapper = new HashSet>(); + + public T GetModel(U entity) + { + var result = mapper.Where(tuple => tuple.Item2.Equals(entity)); + if(result.Count() != 1) + { + return default(T); + } + return result.First().Item1; + } + + public U GetEntity(T model) + { + var result = mapper.Where(tuple => tuple.Item1.Equals(model)); + if(result.Count() != 1) + { + return default(U); + } + return result.First().Item2; + } + + public void Add(T model, U entity) + { + mapper.Add(Tuple.Create(model, entity)); + } + + public void AddRange(params Tuple[] tuples) + { + foreach(var t in tuples) + { + Add(t.Item1, t.Item2); + } + } + + public EnumsMapper(params Tuple[] tuples) + { + AddRange(tuples); + } + } +} + diff --git a/Sources/Utils/Mapper.cs b/Sources/Utils/Mapper.cs new file mode 100644 index 0000000..2021b2f --- /dev/null +++ b/Sources/Utils/Mapper.cs @@ -0,0 +1,46 @@ + using System; +using System.Collections.Generic; +using System.Linq; + +namespace Utils +{ + public class Mapper where T : class + where U : class + { + readonly HashSet> mapper = new HashSet>(); + + public void Reset() + { + mapper.Clear(); + } + + public T GetT(U entity) + { + var result = mapper.Where(tuple => ReferenceEquals(tuple.Item2, entity)); + if(result.Count() != 1) + { + return null; + } + return result.First().Item1; + } + + public U GetU(T model) + { + var result = mapper.Where(tuple => ReferenceEquals(tuple.Item2, model)); + if(result.Count() != 1) + { + return null; + } + return result.First().Item2; + } + + public bool AddMapping(T t, U u) + { + var mapping = new Tuple(t, u); + if(mapper.Contains(mapping)) return false; + mapper.Add(mapping); + return true; + } + } +} + diff --git a/Sources/Utils/Utils.csproj b/Sources/Utils/Utils.csproj new file mode 100644 index 0000000..c01993f --- /dev/null +++ b/Sources/Utils/Utils.csproj @@ -0,0 +1,7 @@ + + + + net7.0 + + +