testade calibre
This commit is contained in:
44
Server/Business/Services/CalibreService.cs
Normal file
44
Server/Business/Services/CalibreService.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Bibblan.Models;
|
||||
using Bibblan.ViewModels;
|
||||
|
||||
namespace Bibblan.Business.Services
|
||||
{
|
||||
public class CalibreService
|
||||
{
|
||||
CalibreContext _context;
|
||||
public CalibreService(CalibreContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IQueryable<BookVm> GetAllBooks()
|
||||
{
|
||||
return from b in _context.Books
|
||||
join ba in _context.BooksAuthorsLink on b.Id equals ba.Book
|
||||
join a in _context.Authors on ba.Author equals a.Id
|
||||
join comment in _context.Comments on b.Id equals comment.Book into comments
|
||||
from comment in comments.DefaultIfEmpty()
|
||||
join bl in _context.BooksLanguagesLink on b.Id equals bl.Book
|
||||
join l in _context.Languages on bl.LangCode equals l.Id
|
||||
join bs in _context.BooksSeriesLink on b.Id equals bs.Book into book_series_link
|
||||
from bs in book_series_link.DefaultIfEmpty()
|
||||
join s in _context.Series on bs.Series equals s.Id into series
|
||||
from s in series.DefaultIfEmpty()
|
||||
orderby b.Title
|
||||
select new BookVm
|
||||
{
|
||||
Id = b.Id,
|
||||
Title = b.Title,
|
||||
AuthorId = a.Id,
|
||||
Author = a.Sort,
|
||||
Comments = comment.Text,
|
||||
Language = l.LangCode,
|
||||
Path = b.Path,
|
||||
HasCover = b.HasCover == "1",
|
||||
Formats = (from d in _context.Data where d.Book == b.Id orderby d.Format select new DataVm { Id = d.Id, Format = d.Format, FileName = d.Name + "." + d.Format.ToLower() }).ToList(),
|
||||
SeriesName = s.Name,
|
||||
SeriesNumber = b.SeriesIndex
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user