public void FillPaySaleRules(SalesRules PaysalesRules) { // SalesRulesRepo repo = new SalesRulesRepo(); //salesRules = repo.GetSalesRules(Category, POS, ServiceType); for (int i = 0; i < PaysalesRules.MarkupList.Count; i++) { MarkUp markUp = new MarkUp() { CommAmt = PaysalesRules.MarkupList[i].commAmount, ID = PaysalesRules.MarkupList[i].ID, MarkupPriority = PaysalesRules.MarkupList[i].Priority, CommRound = PaysalesRules.MarkupList[i].commRound, CommRelatedUnit = PaysalesRules.MarkupList[i].commRelatedUnit, CommType = PaysalesRules.MarkupList[i].commType, markupbase = PaysalesRules.MarkupList[i].Base, markupname = PaysalesRules.MarkupList[i].Name, }; markUp.MarkupCriterias = PaysalesRules.MarkupList[i].CriteriaList.Select(a => new MarkupCriteria() { criterianame = a.criteriaName, criteriavalue = a.value, operation = a.operation, markupid = PaysalesRules.MarkupList[i].ID.ToString(), CriteriaValueText = a.textValue }).ToList(); MarkupList.Add(markUp); } /* for (int i = 0; i < salesRules.DiscountList.Count; i++) * { * Discount discount = new Discount() * { * CommAmt = salesRules.DiscountList[i].commAmount, * ID = salesRules.DiscountList[i].ID, * DiscountPriority = salesRules.DiscountList[i].Priority, * commround = salesRules.DiscountList[i].commRound, * commrelatedunit = salesRules.DiscountList[i].commRelatedUnit, * commtype = salesRules.DiscountList[i].commType, * DiscountBase = salesRules.DiscountList[i].Base, * DiscountName = salesRules.DiscountList[i].Name, * * }; * discount.DiscountCriterias = salesRules.DiscountList[i].CriteriaList.Select(a => new DiscountCriteria() * { * criterianame = a.criteriaName, * criteriavalue = a.value, * operation = a.operation, * DiscountID = salesRules.DiscountList[i].ID.ToString(), * CriteriaValueText = a.textValue * }).ToList(); * DiscountList.Add(discount); * }*/ }
// first call to sales rules //////////////////////////////////////////////////////////////// public SalesRules GetSalesRules(string Category, string POS, string Service) { SalesRules salesRules = new SalesRules(); try { var salesRulesData = GetMarkupandDiscount(Category, POS, Service).Result; if (salesRulesData != null) { salesRules.MarkupList = salesRulesData.MarkupList; salesRules.DiscountList = salesRulesData.DiscountList; } } catch (Exception ex) { // CBExceptionsLog.RecordException(ex); } return(salesRules); }
public List <PaymentGateWay> GetPayGateWay(string BN) { try { // get Some data from DB like Currency and pos PayLinkDB DB = new PayLinkDB(); SalesRulesManager ServiceChargeManager = new SalesRulesManager(); string pos; List <string> gates = new List <string>(); List <PaymentGateWay> paymentGateWays = new List <PaymentGateWay>(); // SalesRuleGateway salesRule = new SalesRuleGateway(); SalesRules salesRule = new SalesRules(); var criterais = DB.GetDataForGatewayDA(BN); //call selected Gateway //basecurr var BaseCur = ConfigurationSettings.AppSettings["BaseCur"]; // exchangeRate CurrencyRepo currencyManager = new CurrencyRepo(); double ExcahngeRate = currencyManager.GetEveryDayCurrenciesConversion(BaseCur, criterais.Curr, criterais.searchData.sID, DateTime.Now).Result.Customer_Sell_Rate; double ExcahngeRateForBase = currencyManager.GetEveryDayCurrenciesConversion(criterais.Curr, BaseCur, criterais.searchData.sID, DateTime.Now).Result.Customer_Sell_Rate; if (criterais.Curr != null & criterais.pos != null) { gates = GateWays.GetPaymentGatewaysAsync(criterais.Curr).Result; if (gates.Count == 0) { return(null); } } else { return(null); } // call sales Rules salesRule = GateWays.GetSaleRuleForGateAsync(criterais.pos).Result; if (salesRule.MarkupList.Count == 0) { foreach (var item in gates) { PaymentGateWay gateWay = new PaymentGateWay(); gateWay.paymentMethod = item; gateWay.currency = criterais.Curr; gateWay.amount = 0; paymentGateWays.Add(gateWay); } return(paymentGateWays); } ServiceChargeManager.FillPaySaleRules(salesRule); ServiceChargeManager.PrepareSearchCriteriaDic(criterais.searchData); foreach (var item in gates) { ServiceChargeManager.SetResultCriteriaForpay(criterais.HotelName, criterais.HotelStars, criterais.cost * ExcahngeRateForBase, criterais.Pid, item); //AppliedSalesRule AppliedMarkup = ServiceChargeManager.ApplySalesRules("Markup"); AppliedSalesRule AppliedMarkup = ServiceChargeManager.ApplyMarkupForPayGateway(); PaymentGateWay gateWay = new PaymentGateWay(); gateWay.paymentMethod = item; gateWay.currency = criterais.Curr; if (gateWay.currency.ToLower() == "kwd") { gateWay.amount = Math.Round(AppliedMarkup.Value * ExcahngeRate, 3); } gateWay.amount = Math.Round(AppliedMarkup.Value * ExcahngeRate, 2); paymentGateWays.Add(gateWay); } return(paymentGateWays); /// AppliedSalesRule AppliedDiscount = ServiceChargeManager.ApplySalesRules("Discount"); // map /* foreach (var item in salesRule.MarkupList) * { * foreach (var gate in item.CriteriaList) * { * foreach (var g in gates) * { * * * if (g.ToLower() == gate.value.ToLower()) * { * PaymentGateWay gateWay = new PaymentGateWay(); * gateWay.paymentMethod = g; * gateWay.currency = BaseCur; * gateWay.amount = item.commAmount; * gateWay.exchangeRate = ExcahngeRate; * paymentGateWays.Add(gateWay); * } * } * } * }*/ } catch (Exception ex) { return(null); } }