Skip to content

Commit

Permalink
fix: Remove image constraint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
foxminchan committed Aug 26, 2024
1 parent 47f2558 commit 5dc2b71
Show file tree
Hide file tree
Showing 9 changed files with 985 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/BookWorm.Catalog/Domain/BookAggregate/Book.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Book(
Status status,
Guid categoryId,
Guid publisherId,
List<Guid> authorIds)
Guid[] authorIds)
{
Name = Guard.Against.NullOrEmpty(name);
Description = Guard.Against.NullOrEmpty(description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ public BookFilterSpec(
{
Query.Where(x => !x.IsDeleted);

if (statuses is not null)
if (statuses is not null && statuses.Length > 0)
{
Query.Where(book => statuses.Contains(book.Status));
}

if (categoryId is not null)
if (categoryId is not null && categoryId.Length > 0)
{
Query.Where(book => categoryId.Contains(book.Category!.Id));
}

if (publisherId is not null)
if (publisherId is not null && publisherId.Length > 0)
{
Query.Where(book => publisherId.Contains(book.Publisher!.Id));
}

if (authorIds is not null)
if (authorIds is not null && authorIds.Length > 0)
{
Query.Where(book => book.BookAuthors.Any(author => authorIds.Contains(author.Id)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed record CreateBookCommand(
Status Status,
Guid CategoryId,
Guid PublisherId,
List<Guid> AuthorIds) : ICommand<Result<Guid>>;
Guid[] AuthorIds) : ICommand<Result<Guid>>;

public sealed class CreateBookHandler(
IRepository<Book> repository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed record CreateBookRequest(
Status Status,
Guid CategoryId,
Guid PublisherId,
List<Guid> AuthorIds);
Guid[] AuthorIds);

public sealed class CreateBookEndpoint : IEndpoint<Created<Guid>, CreateBookRequest, ISender>
{
Expand All @@ -27,7 +27,7 @@ public void MapEndpoint(IEndpointRouteBuilder app)
[FromForm] Status status,
[FromForm] Guid categoryId,
[FromForm] Guid publisherId,
[FromForm] List<Guid> authorIds,
[FromForm] Guid[] authorIds,
IFormFile? image,
ISender sender)
=> await HandleAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public override void Configure(EntityTypeBuilder<Book> builder)
);

builder.Property(x => x.ImageUrl)
.HasMaxLength(DataSchemaLength.SuperLarge)
.IsRequired();
.HasMaxLength(DataSchemaLength.SuperLarge);

builder.Property(p => p.AverageRating)
.HasDefaultValue(0.0);
Expand Down
Loading

0 comments on commit 5dc2b71

Please sign in to comment.