Skip to content

Instantly share code, notes, and snippets.

@MisinformedDNA
Last active June 13, 2023 21:35
Show Gist options
  • Save MisinformedDNA/d0ab6f7d630935940829d9af0bb0f380 to your computer and use it in GitHub Desktop.
Save MisinformedDNA/d0ab6f7d630935940829d9af0bb0f380 to your computer and use it in GitHub Desktop.
Accessing product context from order context
using ProductManager.Shared;
services.AddTransient<IGetProductsQuery, GetProductsQuery>();
using ProductManager.Shared
public class OrderService
{
public OrderService(IGetProductFormulaQuery getProductFormulaQuery) _getProductFormulaQuery = getProductFormulaQuery;
public List<OrderDto> Get()
{
var products = _mediator.Send(_getProductFormulaQuery); // without parameter
}
}
public interface IProductService
{
List<ProductDto> GetByOrder(int orderId);
}
public class ProductService : IProductService
{
public List<ProductDto> GetByOrder(int orderId) { }
}
public record ProductDto(int Id);
public interface IGetProductsQuerys(int orderId) : IRequest<List<Product>> { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment