Skip to content

Commit 4c1955b

Browse files
committed
fix: Remove image constraint issue
1 parent 47f2558 commit 4c1955b

File tree

10 files changed

+986
-47
lines changed

10 files changed

+986
-47
lines changed

src/BookWorm.Catalog/Domain/BookAggregate/Book.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public Book(
1818
Status status,
1919
Guid categoryId,
2020
Guid publisherId,
21-
List<Guid> authorIds)
21+
Guid[] authorIds)
2222
{
2323
Name = Guard.Against.NullOrEmpty(name);
2424
Description = Guard.Against.NullOrEmpty(description);

src/BookWorm.Catalog/Domain/BookAggregate/BookAuthor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace BookWorm.Catalog.Domain.BookAggregate;
22

3-
public class BookAuthor : EntityBase
3+
public sealed class BookAuthor : EntityBase
44
{
55
private BookAuthor()
66
{

src/BookWorm.Catalog/Domain/BookAggregate/Specifications/BookFilterSpec.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ public BookFilterSpec(
1515
{
1616
Query.Where(x => !x.IsDeleted);
1717

18-
if (statuses is not null)
18+
if (statuses is not null && statuses.Length > 0)
1919
{
2020
Query.Where(book => statuses.Contains(book.Status));
2121
}
2222

23-
if (categoryId is not null)
23+
if (categoryId is not null && categoryId.Length > 0)
2424
{
2525
Query.Where(book => categoryId.Contains(book.Category!.Id));
2626
}
2727

28-
if (publisherId is not null)
28+
if (publisherId is not null && publisherId.Length > 0)
2929
{
3030
Query.Where(book => publisherId.Contains(book.Publisher!.Id));
3131
}
3232

33-
if (authorIds is not null)
33+
if (authorIds is not null && authorIds.Length > 0)
3434
{
3535
Query.Where(book => book.BookAuthors.Any(author => authorIds.Contains(author.Id)));
3636
}

src/BookWorm.Catalog/Features/Books/Create/CreateBookCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public sealed record CreateBookCommand(
1111
Status Status,
1212
Guid CategoryId,
1313
Guid PublisherId,
14-
List<Guid> AuthorIds) : ICommand<Result<Guid>>;
14+
Guid[] AuthorIds) : ICommand<Result<Guid>>;
1515

1616
public sealed class CreateBookHandler(
1717
IRepository<Book> repository,

src/BookWorm.Catalog/Features/Books/Create/CreateBookEndpoint.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public sealed record CreateBookRequest(
1313
Status Status,
1414
Guid CategoryId,
1515
Guid PublisherId,
16-
List<Guid> AuthorIds);
16+
Guid[] AuthorIds);
1717

1818
public sealed class CreateBookEndpoint : IEndpoint<Created<Guid>, CreateBookRequest, ISender>
1919
{
@@ -27,7 +27,7 @@ public void MapEndpoint(IEndpointRouteBuilder app)
2727
[FromForm] Status status,
2828
[FromForm] Guid categoryId,
2929
[FromForm] Guid publisherId,
30-
[FromForm] List<Guid> authorIds,
30+
[FromForm] Guid[] authorIds,
3131
IFormFile? image,
3232
ISender sender)
3333
=> await HandleAsync(

src/BookWorm.Catalog/Infrastructure/Data/Configurations/BookConfiguration.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public override void Configure(EntityTypeBuilder<Book> builder)
2222
);
2323

2424
builder.Property(x => x.ImageUrl)
25-
.HasMaxLength(DataSchemaLength.SuperLarge)
26-
.IsRequired();
25+
.HasMaxLength(DataSchemaLength.SuperLarge);
2726

2827
builder.Property(p => p.AverageRating)
2928
.HasDefaultValue(0.0);

0 commit comments

Comments
 (0)