public SaveBasePricesSerializeAction(IFuelPumpRestClient fuelPumpRestClient, ICacheManager cacheManager, FuelPrices prices) : base("SaveBasePrices") { _fuelPumpRestClient = fuelPumpRestClient; _cacheManager = cacheManager; _contract = new FuelPricesContract { isReadTotalizerChecked = prices.IsReadTotalizerChecked, isPricesToDisplayChecked = prices.IsPricesToDisplayChecked, isReadTankDipChecked = prices.IsReadTankDipChecked, tillNumber = _cacheManager.TillNumberForSale, fuelPrices = (from f in prices.Prices select new FuelPriceContract { cashPrice = f.CashPrice, creditPrice = f.CreditPrice, grade = f.Grade, gradeId = f.GradeId, level = f.Level, levelId = f.LevelId, taxExemptedCashPrice = f.TaxExemptedCashPrice, taxExemptedCreditPrice = f.TaxExemptedCreditPrice, tier = f.Tier, tierId = f.TierId, row = f.Row }).ToList() }; }
protected async override Task <object> OnPerform() { var payLoad = new FuelPricesContract { fuelPrices = _fuelPrices != null ? (from f in _fuelPrices.Prices select new FuelPriceContract { cashPrice = f.CashPrice, creditPrice = f.CreditPrice, grade = f.Grade, gradeId = f.GradeId, level = f.Level, levelId = f.LevelId, taxExemptedCashPrice = f.TaxExemptedCashPrice, taxExemptedCreditPrice = f.TaxExemptedCreditPrice, tier = f.Tier, tierId = f.TierId, row = f.Row }).ToList() : new List <FuelPriceContract>(), isReadTotalizerChecked = _fuelPrices.IsReadTotalizerChecked, isReadTankDipChecked = _fuelPrices.IsReadTankDipChecked, isPricesToDisplayChecked = _fuelPrices.IsPricesToDisplayChecked, isTaxExemptionVisible = _fuelPrices.IsTaxExemptionVisible, canReadTotalizer = _fuelPrices.CanReadTotalizer, canSelectPricesToDisplay = _fuelPrices.CanSelectPricesToDisplay, caption = _fuelPrices.Caption, tillNumber = _cacheManager.TillNumberForSale }; var contract = JsonConvert.SerializeObject(payLoad); var content = new StringContent(contract, Encoding.UTF8, ApplicationJSON); var response = await _fuelPumpRestClient.VerifyBasePrices(content); var data = await response.Content.ReadAsStringAsync(); switch (response.StatusCode) { case HttpStatusCode.OK: var responseContract = new DeSerializer().MapSuccess(data); return(responseContract?.success); case HttpStatusCode.Conflict: throw PumpsOfflineException(data); default: return(await HandleExceptions(response)); } }