Merged develop in
This commit is contained in:
commit
5423526484
260 changed files with 15553 additions and 2369 deletions
|
@ -3,6 +3,7 @@ using System.Linq;
|
|||
using API.Data.Migrations;
|
||||
using API.DTOs;
|
||||
using API.DTOs.Account;
|
||||
using API.DTOs.Collection;
|
||||
using API.DTOs.CollectionTags;
|
||||
using API.DTOs.Dashboard;
|
||||
using API.DTOs.Device;
|
||||
|
@ -10,6 +11,7 @@ using API.DTOs.Filtering;
|
|||
using API.DTOs.Filtering.v2;
|
||||
using API.DTOs.MediaErrors;
|
||||
using API.DTOs.Metadata;
|
||||
using API.DTOs.Progress;
|
||||
using API.DTOs.Reader;
|
||||
using API.DTOs.ReadingLists;
|
||||
using API.DTOs.Recommendation;
|
||||
|
@ -52,6 +54,8 @@ public class AutoMapperProfiles : Profile
|
|||
CreateMap<Chapter, ChapterDto>();
|
||||
CreateMap<Series, SeriesDto>();
|
||||
CreateMap<CollectionTag, CollectionTagDto>();
|
||||
CreateMap<AppUserCollection, AppUserCollectionDto>()
|
||||
.ForMember(dest => dest.Owner, opt => opt.MapFrom(src => src.AppUser.UserName));
|
||||
CreateMap<Person, PersonDto>();
|
||||
CreateMap<Genre, GenreTagDto>();
|
||||
CreateMap<Tag, TagDto>();
|
||||
|
@ -140,10 +144,6 @@ public class AutoMapperProfiles : Profile
|
|||
opt =>
|
||||
opt.MapFrom(
|
||||
src => src.Genres.OrderBy(p => p.NormalizedTitle)))
|
||||
.ForMember(dest => dest.CollectionTags,
|
||||
opt =>
|
||||
opt.MapFrom(
|
||||
src => src.CollectionTags.OrderBy(p => p.NormalizedTitle)))
|
||||
.ForMember(dest => dest.Tags,
|
||||
opt =>
|
||||
opt.MapFrom(
|
||||
|
|
72
API/Helpers/Builders/AppUserCollectionBuilder.cs
Normal file
72
API/Helpers/Builders/AppUserCollectionBuilder.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
using System.Collections.Generic;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Extensions;
|
||||
using API.Services.Plus;
|
||||
|
||||
namespace API.Helpers.Builders;
|
||||
|
||||
public class AppUserCollectionBuilder : IEntityBuilder<AppUserCollection>
|
||||
{
|
||||
private readonly AppUserCollection _collection;
|
||||
public AppUserCollection Build() => _collection;
|
||||
|
||||
public AppUserCollectionBuilder(string title, bool promoted = false)
|
||||
{
|
||||
title = title.Trim();
|
||||
_collection = new AppUserCollection()
|
||||
{
|
||||
Id = 0,
|
||||
NormalizedTitle = title.ToNormalized(),
|
||||
Title = title,
|
||||
Promoted = promoted,
|
||||
Summary = string.Empty,
|
||||
AgeRating = AgeRating.Unknown,
|
||||
Source = ScrobbleProvider.Kavita,
|
||||
Items = new List<Series>()
|
||||
};
|
||||
}
|
||||
|
||||
public AppUserCollectionBuilder WithSource(ScrobbleProvider provider)
|
||||
{
|
||||
_collection.Source = provider;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public AppUserCollectionBuilder WithSummary(string summary)
|
||||
{
|
||||
_collection.Summary = summary;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppUserCollectionBuilder WithIsPromoted(bool promoted)
|
||||
{
|
||||
_collection.Promoted = promoted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppUserCollectionBuilder WithItem(Series series)
|
||||
{
|
||||
_collection.Items ??= new List<Series>();
|
||||
_collection.Items.Add(series);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppUserCollectionBuilder WithItems(IEnumerable<Series> series)
|
||||
{
|
||||
_collection.Items ??= new List<Series>();
|
||||
foreach (var s in series)
|
||||
{
|
||||
_collection.Items.Add(s);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppUserCollectionBuilder WithCoverImage(string cover)
|
||||
{
|
||||
_collection.CoverImage = cover;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Services.Tasks.Scanner.Parser;
|
||||
|
@ -36,7 +35,7 @@ public class ChapterBuilder : IEntityBuilder<Chapter>
|
|||
var specialTitle = specialTreatment ? Parser.RemoveExtensionIfSupported(info.Filename) : info.Chapters;
|
||||
var builder = new ChapterBuilder(Parser.DefaultChapter);
|
||||
|
||||
return builder.WithNumber(Parser.RemoveExtensionIfSupported(info.Chapters))
|
||||
return builder.WithNumber(Parser.RemoveExtensionIfSupported(info.Chapters)!)
|
||||
.WithRange(specialTreatment ? info.Filename : info.Chapters)
|
||||
.WithTitle((specialTreatment && info.Format == MangaFormat.Epub)
|
||||
? info.Title
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using API.Entities;
|
||||
using API.Entities.Metadata;
|
||||
using API.Extensions;
|
||||
|
||||
namespace API.Helpers.Builders;
|
||||
|
||||
public class CollectionTagBuilder : IEntityBuilder<CollectionTag>
|
||||
{
|
||||
private readonly CollectionTag _collectionTag;
|
||||
public CollectionTag Build() => _collectionTag;
|
||||
|
||||
public CollectionTagBuilder(string title, bool promoted = false)
|
||||
{
|
||||
title = title.Trim();
|
||||
_collectionTag = new CollectionTag()
|
||||
{
|
||||
Id = 0,
|
||||
NormalizedTitle = title.ToNormalized(),
|
||||
Title = title,
|
||||
Promoted = promoted,
|
||||
Summary = string.Empty,
|
||||
SeriesMetadatas = new List<SeriesMetadata>()
|
||||
};
|
||||
}
|
||||
|
||||
public CollectionTagBuilder WithId(int id)
|
||||
{
|
||||
_collectionTag.Id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CollectionTagBuilder WithSummary(string summary)
|
||||
{
|
||||
_collectionTag.Summary = summary;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CollectionTagBuilder WithIsPromoted(bool promoted)
|
||||
{
|
||||
_collectionTag.Promoted = promoted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CollectionTagBuilder WithSeriesMetadata(SeriesMetadata seriesMetadata)
|
||||
{
|
||||
_collectionTag.SeriesMetadatas ??= new List<SeriesMetadata>();
|
||||
_collectionTag.SeriesMetadatas.Add(seriesMetadata);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CollectionTagBuilder WithCoverImage(string cover)
|
||||
{
|
||||
_collectionTag.CoverImage = cover;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ public class MangaFileBuilder : IEntityBuilder<MangaFile>
|
|||
{
|
||||
_mangaFile = new MangaFile()
|
||||
{
|
||||
FilePath = filePath,
|
||||
FilePath = Parser.NormalizePath(filePath),
|
||||
Format = format,
|
||||
Pages = pages,
|
||||
LastModified = File.GetLastWriteTime(filePath),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using API.Data;
|
||||
using API.Entities;
|
||||
|
@ -75,4 +76,18 @@ public class VolumeBuilder : IEntityBuilder<Volume>
|
|||
_volume.CoverImage = cover;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VolumeBuilder WithCreated(DateTime created)
|
||||
{
|
||||
_volume.Created = created;
|
||||
_volume.CreatedUtc = created.ToUniversalTime();
|
||||
return this;
|
||||
}
|
||||
|
||||
public VolumeBuilder WithLastModified(DateTime lastModified)
|
||||
{
|
||||
_volume.LastModified = lastModified;
|
||||
_volume.LastModifiedUtc = lastModified.ToUniversalTime();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using API.Entities;
|
||||
|
||||
namespace API.Helpers;
|
||||
|
@ -46,6 +47,7 @@ public static class OrderableHelper
|
|||
|
||||
public static void ReorderItems(List<ReadingListItem> items, int readingListItemId, int toPosition)
|
||||
{
|
||||
if (toPosition < 0) throw new ArgumentException("toPosition cannot be less than 0");
|
||||
var item = items.Find(r => r.Id == readingListItemId);
|
||||
if (item != null)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue