public AdditionalFees Get(string CardId, int installments) { AdditionalFees found = null; var result = (from c in _cards.Card where c.CardId == CardId from i in c.InstallmentFees where i.InstallmentNumber == installments select i); if (null != result && result.Count() > 0) { found = new AdditionalFees(); found.Installments = result.FirstOrDefault().InstallmentNumber; found.Rate = result.FirstOrDefault().FeeRate; } return(found); }
private int GetFeeAmount() { int installments = 0; decimal feePrice = 0.0M; decimal totalDue = 0M; if (int.TryParse(ddlInstallments.SelectedValue, out installments)) { if (installments > 1) { OrderTotals_V01 totals = _page.ShoppingCart.Totals as OrderTotals_V01; SKU_V01 feeSku = null; if (_page.AllSKUS.TryGetValue(_cards.FeeSKU, out feeSku)) { feePrice = feeSku.CatalogItem.ListPrice; var fees = new AdditionalFees(_cards); decimal coefficient = fees.GetCoefficient(ddlCards.SelectedValue, installments); if (totals.ItemsTotal > 0) { totalDue = (totals.AmountDue) * (coefficient); } } else { string errorMessage = string.Format( "Cannot find Credit Card Installment SKU {0}. Cannot calculate fees for Payment Installments", _cards.FeeSKU); LoggerHelper.Error(errorMessage); throw new ApplicationException(errorMessage); } } } return((totalDue > 0) ? int.Parse(Math.Ceiling(totalDue / feePrice).ToString()) : 0); }