/// <summary> /// Fetches a specific product with corresponding meta-data (e.g. pricing tier, initial tariff, ...) /// </summary> /// <param name="id">Product ID to search for</param> public async Task <ProductDTO> Get(Guid id) { using (_dbContext) { ProductEntity product = await _dbContext.Products.FindAsync(id); if (product != null) { // Load additional data (used this way to have the benefits of Find() by still including external data) await _dbContext.Entry(product).Reference(p => p.InitialTariff).LoadAsync(); if (product.InitialTariff != null) { await _dbContext.Entry(product.InitialTariff).Reference(t => t.NextPricingTier).LoadAsync(); } return(product.Adapt <ProductDTO>()); } return(null); } }
/// <summary> /// Fetches a specific tariff with corresponding meta-data (e.g. pricing tier, initial tariff, ...) /// </summary> /// <param name="id">Product ID to search for</param> public async Task <TariffDTO> Get(Guid id) { using (_dbContext) { TariffEntity tariff = await _dbContext.Tariffs.FindAsync(id); if (tariff != null) { // Load additional data (used this way to have the benefits of Find() by still including external data) await _dbContext.Entry(tariff).Reference(t => t.NextPricingTier).LoadAsync(); return(tariff.Adapt <TariffDTO>()); } return(null); } }