Beispiel #1
0
        private IEnumerable <IbsChargeAccount> GetNewChargeAccounts(List <IbsChargeAccount> ibsAccounts)
        {
            var taxiHailChargeAccounts = _dao.GetAll();

            var newChargeAccounts = ibsAccounts.Where(
                ibsChargeAccount =>
                taxiHailChargeAccounts.All(currentAccount => currentAccount.Number != ibsChargeAccount.AccountNumber));

            return(newChargeAccounts);
        }
Beispiel #2
0
        public object Get(AccountChargeRequest request)
        {
            var isAdmin = SessionAs <AuthUserSession>().HasPermission(RoleName.Admin);

            if (!request.AccountNumber.HasValue())
            {
                var allAccounts = _dao.GetAll();

                if (request.HideAnswers || !isAdmin)
                {
                    foreach (var account in allAccounts)
                    {
                        HideAnswers(account.Questions);
                    }
                }
                return(allAccounts
                       .Select(acc => new
                {
                    acc.Name,
                    AccountNumber = acc.Number,
                    acc.Questions,
                    acc.Id,
                    acc.UseCardOnFileForPayment
                })
                       .ToArray());
            }
            else
            {
                // Validate locally that the account exists
                var account = _dao.FindByAccountNumber(request.AccountNumber);
                if (account == null)
                {
                    throw new HttpError(HttpStatusCode.NotFound, "Account Not Found");
                }

                // Validate with IBS to make sure the account/customer is still active
                var ibsChargeAccount = _ibsServiceProvider.ChargeAccount().GetIbsAccount(request.AccountNumber, request.CustomerNumber ?? "0");
                if (ibsChargeAccount == null || !ibsChargeAccount.IsValid())
                {
                    throw new HttpError(HttpStatusCode.NotFound, "Account Not Found");
                }

                var customerSpecificQuestions = ibsChargeAccount.Prompts.ToArray();

                var questionsToRemove = account.Questions.Where(question => question.Question.HasValueTrimmed() && customerSpecificQuestions.None(prompt => question.Question == prompt.Caption))
                                        .ToArray();

                account.Questions.Remove(p => questionsToRemove.Contains(p));

                if (questionsToRemove.Any())
                {
                    foreach (var t in questionsToRemove)
                    {
                        account.Questions.Add(new AccountChargeQuestion
                        {
                            Id              = t.Id,
                            IsRequired      = false,
                            IsCaseSensitive = false,
                            AccountId       = account.Id
                        });
                    }
                }

                if (request.HideAnswers || !isAdmin)
                {
                    HideAnswers(account.Questions);
                }

                var currentUser = new Guid(this.GetSession().UserAuthId);
                LoadCustomerAnswers(account.Questions, currentUser);

                return(account);
            }
        }