public async Task LoadCoupons() { IsBusy = true; LoadingMessage = "Loading..."; var surveyResponses = await ServiceLocator.AzureService.GetSurveyResponsesByUserId(Helpers.Settings.UserId); if (surveyResponses.Count > 0) { foreach (SurveyResponse s in surveyResponses) { if (s.CouponId != null) { var coupon = await ServiceLocator.AzureService.GetById <Coupon>(s.CouponId); coupon.CreatedDate = s.CreatedAt; Coupons.Add(coupon); } } } else { await couponsPage.DisplayAlert("Sorry", "No coupons available, please take a survey.", "ok"); } IsBusy = false; }
private async Task SearchCouponsAsync(string searchInput) { var results = await couponService.SearchCoupons(searchInput); Coupons.Clear(); foreach (var c in results) { var viewModel = new CouponViewModel(c); var couponImageName = await couponService.GetCouponImageName(c); viewModel.PhotoUrl = fileHelper.GetLocalFilePath(c.Id, couponImageName); Coupons.Add(viewModel); } }
async Task LoadCoupons() { IsBusy = true; var coupons = await CouponManager.GetAsync(); Coupons.Clear(); foreach (var coupon in coupons) { Coupons.Add(coupon); } IsBusy = false; }
private void InitCoupons() { Coupon coupon1 = new Coupon(); Coupon coupon2 = new Coupon(); Coupon coupon3 = new Coupon(); coupon1.Id = 1; coupon1.Luggages = Luggages; coupon1.Flight = Flights.Find(f => f.Id == 1); coupon2.Id = 2; coupon2.Flight = Flights.Find(f => f.Id == 2); coupon2.Luggages.Add(Luggages.Find(l => l.Weight == 50)); coupon3.Id = 3; Coupons.Add(coupon1); Coupons.Add(coupon2); Coupons.Add(coupon3); Flights.Find(f => f.Id == 1).Coupons.Add(coupon1); Flights.Find(f => f.Id == 2).Coupons.Add(coupon2); }
public void AddCoupon(PriceableRateCoupon newFlow) { Coupons.Add(newFlow); }
public void AddCoupon(PriceableCapFloorCoupon newFlow) { Coupons.Add(newFlow); }
public Cart(Basket apiBasket) : this() { if (apiBasket.Items.Any()) { foreach (var item in apiBasket.Items) { CartItemCount += (int)item.Quantity; var cartItem = new CartItem { Name = item.Name, ProductId = item.Id.ToString(), Quantity = (int)item.Quantity, ItemPrice = new Price(item.BasePrice.ToString()), TotalPrice = new Price(item.AdjustedPrice.ToString()) }; if (item.PriceAdjustments.Any()) { cartItem.ListPrice = new Price(item.Price.ToString()); cartItem.CouponDiscount = new Price(item.PriceAdjustments.FirstOrDefault().Discount.ToString()) { Label = item.PriceAdjustments.FirstOrDefault().Description }; } CartItems.Add(cartItem); } // Summary Summary.Costs.Add(new Price(apiBasket.ProductSubTotal.ToString()) { Label = "Subtotal: " }); if (apiBasket.PriceAdjustments.Any()) { var discount = 0.0M; var description = string.Empty; apiBasket.PriceAdjustments.ForEach(x => { discount += x.Discount; description += "<br>" + x.Description; }); Summary.Costs.Add(new Price(discount.ToString()) { Label = string.Format("Order Discount: {0}", description) }); } if (apiBasket.ShippingTotal > 0) { Summary.Costs.Add(new Price(apiBasket.ShippingTotal.ToString()) { Label = "Shipping: " }); } Summary.Total = new Price(apiBasket.OrderTotal.ToString()) { Label = "Estimated Total: " }; // Coupons apiBasket.Coupons.ForEach(x => { var message = string.Empty; switch (x.StatusCode) { case CouponCodeStatusCodeEnum.applied: message = Config.Constants.CouponAppliedMessage; break; case CouponCodeStatusCodeEnum.no_applicable_promotion: message = Config.Constants.CouponNAMessage; break; default: message = Config.Constants.CouponInvalidMessage; break; } Coupons.Add(new CouponCodeBase { Code = x.Code, CouponValue = new Price(), Message = string.Format(message, x.Code) }); }); } }