Ejemplo n.º 1
0
        public ResponseBase CanScrubCustomer(Account account)
        {
            var response = new ResponseBase();

            // Does account have more than one contract?
            var contracts = _contractRepository.GetContractsByAccountId(account.Id.Value);

            var master = account as MasterAccount;
            if (master != null)
            {
                var subAccounts = _accountRepository.GetAllSubAccounts(master.Id.Value);
                if (subAccounts.Count > 0)
                {
                    response.IsSuccessful = false;
                    response.Message = "This Account has sub-accounts.  Cannot Delete";
                    return response;
                }
            } else {
                response.IsSuccessful = false;
                response.Message = "This Account is a sub-account. Cannot Delete";
            }

            if (contracts.Count > 1)
            {
                response.IsSuccessful = false;
                response.Message = "This Customer has multiple Contracts.  Cannot Delete.";
                return response;
            }

            response.IsSuccessful = true;
            return response;
        }
Ejemplo n.º 2
0
        public void InsertAccount(AirtimeBilling.Core.Entities.Account account)
        {
            using (var db = DbFactory.GetDataContext())
            {
                var acc = new Account();
                acc.PopulateFromEntity(account);

                db.Accounts.InsertOnSubmit(acc);
                db.SubmitChanges();
                account.Inserted(acc.AccountId);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Delete's all evidence of a Customer having been in the sytem.
        /// </summary>
        /// <param name="account">Single account to delete</param>        
        public ResponseBase ScrubCustomer(Account account)
        {
            if (_invoicingService == null) _invoicingService = ServiceFactory.GetService<IInvoicingService>(); // yuk hack

            var response = new ResponseBase();

            // Does account have more than one contract?
            var contracts = _contractRepository.GetContractsByAccountId(account.Id.Value);

            if (contracts.Count == 0)
            {
                response.IsSuccessful = false;
                return response;
            }

            response = CanScrubCustomer(account);
            if (!response.IsSuccessful) return response;

            // Delete Invoices
            if (!DeleteInvoices(account)) {
                response.IsSuccessful = false;
                response.Message = "Could not delete Invoices";
                return response;
            }

            // Call normal Scrub Contract
            return ScrubContract(contracts[0]);
        }
Ejemplo n.º 4
0
        private bool DeleteInvoices(Account account)
        {
            using (var ts = new TransactionScope()) {
                var invoices = _invoiceRepository.GetAllInvoiceForAccount(account);

                foreach (var invoice in invoices) {

                    var success = _invoiceRepository.DeleteInvoice(invoice);
                    if (!success) {
                        return false;
                    }

                }

                ts.Complete();
                return true;
            }
        }
Ejemplo n.º 5
0
 partial void UpdateAccount(Account instance);
Ejemplo n.º 6
0
 partial void DeleteAccount(Account instance);
Ejemplo n.º 7
0
 partial void InsertAccount(Account instance);
Ejemplo n.º 8
0
		private void detach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.Company = null;
		}
Ejemplo n.º 9
0
		private void attach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.Company = this;
		}
Ejemplo n.º 10
0
		private void detach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.ParentAccount = null;
		}
Ejemplo n.º 11
0
		private void attach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.ParentAccount = this;
		}