示例#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;
        }
示例#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);
            }
        }
示例#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]);
        }
示例#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;
            }
        }
示例#5
0
 partial void UpdateAccount(Account instance);
示例#6
0
 partial void DeleteAccount(Account instance);
示例#7
0
 partial void InsertAccount(Account instance);
示例#8
0
		private void detach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.Company = null;
		}
示例#9
0
		private void attach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.Company = this;
		}
示例#10
0
		private void detach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.ParentAccount = null;
		}
示例#11
0
		private void attach_Accounts(Account entity)
		{
			this.SendPropertyChanging();
			entity.ParentAccount = this;
		}