Exemple #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;
        }
Exemple #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);
            }
        }
Exemple #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]);
        }
Exemple #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;
            }
        }
 partial void UpdateAccount(Account instance);
 partial void DeleteAccount(Account instance);
 partial void InsertAccount(Account instance);
		private void detach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.Company = null;
		}
		private void attach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.Company = this;
		}
		private void detach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.ParentAccount = null;
		}
		private void attach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.ParentAccount = this;
		}