add supplier attributes

This commit is contained in:
2023-06-12 13:13:40 +02:00
parent 9cb007399a
commit 73bfcccc9c
15 changed files with 218 additions and 46 deletions

View File

@@ -15,6 +15,8 @@ public sealed class RepoDbContext : DbContext
public DbSet<Supplier> Suppliers { get; set; }
public DbSet<ContactPerson> ContactPersons { get; set; }
public DbSet<Product> Products { get; set; }
}

View File

@@ -20,12 +20,12 @@ public class SupplierRepository : ISupplierRepository
public async Task<IEnumerable<Supplier>> GetAllAsync(CancellationToken cancellationToken)
{
return await _dbContext.Suppliers.ToListAsync(cancellationToken);
return await _dbContext.Suppliers.Include(x => x.ContactPersons).ToListAsync(cancellationToken);
}
public async Task<Supplier> GetByIdAsync(Guid supplierId, CancellationToken cancellationToken)
{
return await _dbContext.Suppliers.FirstOrDefaultAsync(x => x.SupplierId == supplierId, cancellationToken);
return await _dbContext.Suppliers.Include(x => x.ContactPersons).FirstOrDefaultAsync(x => x.SupplierId == supplierId, cancellationToken);
}
public void Insert(Supplier supplier)