Skip to content

Feat/delete catalogs#22

Open
KopfSzmercen wants to merge 17 commits intomainfrom
feat/delete-catalogs
Open

Feat/delete catalogs#22
KopfSzmercen wants to merge 17 commits intomainfrom
feat/delete-catalogs

Conversation

@KopfSzmercen
Copy link
Copy Markdown
Collaborator

No description provided.

bool userCanNotCreateCatalog
)
{
if (userCanNotCreateCatalog)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tutaj to albo nie jest potrzebne albo się źle się nazywa - userCanNotCreateCatalog - to w sumie nic nie mówi jakie są zasady

public string Name { get; private set; }
public string Genre { get; private set; }
public string Description { get; private set; }
public List<Book> Books { get; set; }
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moze nie ma potrzeby trzymania tutaj listy Books na wricie

{
if (updater == Guid.Empty)
throw new UserCanNotUpdateCatalogException();
if (userCanNotUpdateCatalog)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userCanNotUpdateCatalog - ten parametr nic nie mówi co to sprawdza - trzeba lepiej nazwać

{
Task AddAsync(Catalog catalog);

Task<bool> UserCanNotAddCatalogAsync(Guid bookStoreId);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Te nazwy tutaj też niewiele mówią - nie wiadomo co to sprawdza póki się nie wejdzie do implementacji na bazie

if (book is null)
throw new BookNotFoundException();

await catalogRepository.AddBookToCatalogAsync(book, catalog);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

albo catalog.AddBook(book) albo book.SetCatalog(catalog)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nie powinniśmy przekładać odpowiedzialności za procesy biznesowe na repozytorium

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do przemyślenia czy czasem nie zwrobić tak że Book ma public Catalog, a katalog nie ma List - bo za każdym update byśmy musieli to zaciągać z bazy

if (catalog.CreatedBy != context.Identity.Id)
throw new UserCanNotRemoveBookFromCatalogException();

await catalogRepository.RemoveBookFromCatalogAsync(book, catalog);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu też odpowiedzialność za proces jest na repo

builder
.HasMany<Book>()
.WithMany()
.UsingEntity(j => j.ToTable("CatalogBooks"));
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raczej nie ma potrzeby tego tak robić, automatycznie będziemy mieć

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ale to nie jest błąd

}
public async Task<bool> UserCanNotAddCatalogAsync(Guid bookStoreId)
{
return await dbContext.Catalogs.CountAsync(x => x.BookStoreId == bookStoreId) >= 5;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logika na repo - to powinno byc zwracane ale nie sprawdzane tutaj

dbContext.Catalogs.Update(catalog);
await dbContext.SaveChangesAsync();
}
public Task<bool> UserCanNotUpdateCatalogAsync(DateTime lastUpdated, DateTime now)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ta metoda wogóle nie powinna być w repozytorium - sprawdzanie warunków biznesowych zostawmy w domenie

}


public async Task AddBookToCatalogAsync(Book book, Catalog catalog)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To potem też pewnie będzie do zmiany

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants