public void BorrowBookToUser(long bookId, long userAccountId) { try { BorrowBookCommand command = new BorrowBookCommand { BookAggregateRootId = bookId, UserAccountAggregateRootId = userAccountId }; this.CommitCommand(command); } catch (DomainException ex) { WCFServiceFault sf = new WCFServiceFault { Message = ex.Message, StackTrace = ex.StackTrace }; throw new FaultException <WCFServiceFault>(sf, new FaultReason(sf.Message)); } }
private void CommitCommand(ICommand command) { try { using (ICommandBus commandBus = AppRuntime .Instance .CurrentApplication .ObjectContainer .GetService <ICommandBus>()) { commandBus.Publish(command); commandBus.Commit(); } } catch (Exception ex) { WCFServiceFault sf = new WCFServiceFault { Message = ex.Message, StackTrace = ex.StackTrace }; throw new FaultException <WCFServiceFault>(sf, sf.Message); } }