public PaymentTransactionType(DataLoader loader, UserRepository users) { Name = "Payment"; Description = "A payment. The amount will be negative."; TransactionInterfaceType.Implement(this, loader, users); }
public AdjustmentTransactionType(DataLoader loader, UserRepository users) { Name = "Adjustment"; Description = "An adjustment that was made to a user's balance."; TransactionInterfaceType.Implement(this, loader, users); Field(x => x.Description).Description("Justification for the adjustment."); }
public PurchaseTransactionType(DataLoader loader, UserRepository users, ProductRepository products, UserManager <User> userManager, TransactionService transactionService) { Name = "Purchase"; Description = "A product purchase."; TransactionInterfaceType.Implement(this, loader, users); Field("pricePerUnit", x => x.ProductPrice).Description("The unit price of the product at the time of purchase."); Field("itemName", x => x.ProductName).Description("The product's name at the time of purchase."); Field(x => x.Quantity).Description("The quantity that was purchased"); Field("wasFromSubscription", x => x.IsFromSubscription).Description("Indicates if this purchase was triggered by a subscription."); Field <BooleanGraphType>( "canDelete", description: "Indicates if the purchased can be cancelled.", resolve: ctx => { var currentUser = ctx.UserContext.As <DepanneurUserContext>().User; var currentUserId = userManager.GetUserId(currentUser); return(transactionService.CanCancel(currentUserId, ctx.Source)); }); Field <ProductType>("product", resolve: ctx => loader.LoadBatch("GetProductsById", ctx.Source.ProductId, products.GetProductsById)); }