Validation <Guid> Initialize(CreateAccountWithOptions cmd)
            {
                Guid     id  = generateId();
                DateTime now = DateTime.UtcNow;

                var create = new CreateAccount
                             (
                    Timestamp: now,
                    AccountId: id,
                    Currency: cmd.Currency
                             );

                var depositCash = new AcknowledgeCashDeposit
                                  (
                    Timestamp: now,
                    AccountId: id,
                    Amount: cmd.InitialDepositAccount,
                    BranchId: cmd.BranchId
                                  );

                var setOverdraft = new SetOverdraft
                                   (
                    Timestamp: now,
                    AccountId: id,
                    Amount: cmd.AllowedOverdraft
                                   );

                var transitions =
                    from e1 in Account.Create(create)
                    from e2 in Account.Deposit(depositCash)
                    from e3 in Account.SetOverdraft(setOverdraft)
                    select List <Event>(e1, e2, e3);

                return(transitions(default(AccountState))
                       .Do(t => t.Item1.ForEach(saveAndPublish))
                       .Map(_ => id));
            }
 public IActionResult CreateInitialized([FromBody] CreateAccountWithOptions cmd)
 => validate(cmd)
 .Bind(Initialize)
 .Match <IActionResult>(
     Invalid: errs => BadRequest(new { Errors = errs }),
     Valid: id => Ok(id));