Updated the domain model with entities, repos and domain services. Looks good. I think I addressed all the user stories however if I fell short we'll revise as needed.
This commit was merged in pull request #6.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using LibraryApp.Domain;
|
||||
using LibraryApp.Domain.Entities;
|
||||
|
||||
namespace LibraryApp.Domain.Services;
|
||||
|
||||
public class BookCountService
|
||||
{
|
||||
private readonly IBookCountReportPrinter _printer;
|
||||
|
||||
public BookCountService(IBookCountReportPrinter printer)
|
||||
{
|
||||
_printer = printer;
|
||||
}
|
||||
|
||||
public async Task<Result<BookCountReport>> PerformCountAsync(
|
||||
Shelf shelf,
|
||||
IReadOnlyList<BookInstanceBarcode> scannedBarcodes,
|
||||
IReadOnlyList<BookInstance> allInstancesOnShelf)
|
||||
{
|
||||
shelf.RecordCount();
|
||||
|
||||
var report = new BookCountReport(shelf.Id, DateTime.UtcNow, allInstancesOnShelf, scannedBarcodes);
|
||||
|
||||
foreach (var instance in report.MissingInstances)
|
||||
instance.MarkAsLost();
|
||||
|
||||
await _printer.PrintAsync(report);
|
||||
|
||||
return Result<BookCountReport>.Success(report);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user