public AccountBalanceMessageResponse GetAccountBalance() { Account account = new Account(); account.Balance = AccountStore.GetBalance(); AccountBalanceMessageResponse response = new AccountBalanceMessageResponse(); response.Body = account; return response; }
public void PlaceOrder(OrderMessage request) { using (TransactionScope scope = new TransactionScope()) using (ChannelWrapper<IPetShopInventoryService> inventory = new ChannelWrapper<IPetShopInventoryService>("Inventory")) using (ChannelWrapper<IPetShopAccountingService> accounting = new ChannelWrapper<IPetShopAccountingService>("Accounting")) { // update account int total = CalculateTotal(request.Body.ProductName, request.Body.Quantity); Account account = new Account(); account.Balance = total; ChargeAccountMessage accountingMsg = new ChargeAccountMessage(); accountingMsg.Body = account; try { accounting.Channel.ChargeAccount(accountingMsg); } catch (FaultException<AccountingFault> ex) { OrderFault fault = new OrderFault(); fault.Description = ex.Detail.Description; throw new FaultException<OrderFault>(fault, "Order failed"); } // update inventory UpdateInventoryMessage inventoryMsg = new UpdateInventoryMessage(); inventoryMsg.Body = request.Body; try { inventory.Channel.UpdateInventory(inventoryMsg); } catch (FaultException<InventoryFault> ex) { OrderFault fault = new OrderFault(); fault.Description = ex.Detail.Description; throw new FaultException<OrderFault>(fault, "Order failed"); } scope.Complete(); } }