Skip to content

Commit

Permalink
DeleteProduct impl in product repo
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveParry committed Jan 22, 2024
1 parent 68f3ffd commit 21d73ed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Shop/Repository/ProductRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ public async Task<ProductEntity> CreateProduct(ProductEntity productEntity)

public async Task<bool> DeleteProduct(int id)
{
throw new NotImplementedException();
var product = await dbContext.Products.FindAsync(id);

if (product == null) { return false; }

dbContext.Products.Remove(product);
return true;
}

public async Task<ProductEntity> GetProduct(int id)
Expand Down

0 comments on commit 21d73ed

Please sign in to comment.