Ejemplo n.º 1
0
        public ResponseBase MakeInvoiceRoot(int accountId)
        {
            var response = new ResponseBase();

            var account = _accountRepository.GetAccount(accountId);
            if (account == null) {
                response.SetFailure("Could not find Account to updated");
                return response;
            }

            if (account.IsInvoiceRoot) {
                response.IsSuccessful = true;
                return response;
            }

            try {
                account.IsInvoiceRoot = true;
                if (_accountRepository.UpdateAccount(account)) {
                    account.LogActivity("Dettached from Master Account to be an Invoice Root");
                    response.IsSuccessful = true;
                    return response;
                }
            } catch (Exception ex) {
                LoggingUtility.LogException(ex);
                response.SetFailure(Constants.Messages.INTERNAL_ERROR);
            }
            return response;
        }
Ejemplo n.º 2
0
        public ResponseBase ReAttachToMasterAccount(int subAccountId)
        {
            var response = new ResponseBase();
            var subAccount = _accountRepository.GetAccount(subAccountId);

            // verify this is an invoice root account
            if (subAccount is MasterAccount) {
                response.SetFailure("Cannot add the Master Account as a sub Account of another Account.");
                return response;
            }

            if (!subAccount.IsInvoiceRoot) {
                response.SetFailure("Accounts that are already sub-accounts cannot be added as a sub-account");
                return response;
            }

            subAccount.IsInvoiceRoot = false;

            try {
                using (var ts = new TransactionScope()) {

                    if (_accountRepository.UpdateAccount(subAccount)) {

                        subAccount.LogActivity("Re-attached as Sub-Account");
                        response.IsSuccessful = true;
                    }

                    ts.Complete();
                }
            } catch (Exception ex) {
                LoggingUtility.LogException(ex);
                response.SetFailure(Constants.Messages.INTERNAL_ERROR);
            }
            return response;
        }