public object OpenAccount(OpenAccountRequest request)
        {
            if (request.SortCode == null || request.AccountNumber == null || request.Holder == null)
                return this.IncompleteOpenAccountResponse(request, "Enter all Account details.");

            var account = this.factory.Create(request.SortCode, request.AccountNumber, request.Holder);
            this.repository.Add(account);

            try
            {
                this.eventStore.Commit();
            }
            catch (ConcurrencyException)
            {
                return this.IncompleteOpenAccountResponse(request, "Account already exists.");
            }

            var surrogateId = new AccountIdSurrogate(Guid.NewGuid(), request.SortCode, request.AccountNumber);
            this.documents.Store(surrogateId, "AccountIdSurrogates/" + surrogateId.SurrogateId);
            this.documents.SaveChanges();

            return new OpenAccountResponse
                {
                    Id = surrogateId.SurrogateId,
                    GetAllAccountsUri = this.links.Relative(RouteNames.GetAllAccounts)
                };
        }
 private object IncompleteOpenAccountResponse(OpenAccountRequest request, string message)
 {
     return new IncompleteOpenAccountResponse
         {
             Request = request,
             OpenAccountUri = this.links.Relative(RouteNames.OpenAccount),
             GetAllAccountsUri = this.links.Relative(RouteNames.GetAllAccounts),
             Message = message
         };
 }