public OrderRow(long orderId, OrderRowResponseObject orderRowResponse, SveaHttpClient client) { Actions = new OrderRowActions(orderId, orderRowResponse, client); OrderRowId = orderRowResponse.OrderRowId; ArticleNumber = orderRowResponse.ArticleNumber; Name = orderRowResponse.Name; Quantity = orderRowResponse.Quantity; UnitPrice = orderRowResponse.UnitPrice; DiscountPercent = orderRowResponse.DiscountPercent; VatPercent = orderRowResponse.VatPercent; Unit = orderRowResponse.Unit; IsCancelled = orderRowResponse.IsCancelled; AvailableActions = orderRowResponse.Actions; }
public OrderRowActions(long orderId, OrderRowResponseObject orderRowResponse, SveaHttpClient client) { foreach (var action in orderRowResponse.Actions) { switch (action) { case OrderRowActionType.CanCancelRow: CancelOrderRow = async payload => await client.HttpPatch <object>( new Uri($"/api/v1/orders/{orderId}/rows/{orderRowResponse.OrderRowId}", UriKind.Relative), payload); break; case OrderRowActionType.CanUpdateRow: UpdateOrderRow = async payload => await client.HttpPatch <object>( new Uri($"/api/v1/orders/{orderId}/rows/{orderRowResponse.OrderRowId}", UriKind.Relative), payload); break; } } }