/// <summary> /// Return the list of TaxApplicability /// </summary> /// <returns>TaxApplicabilityList</returns> public async Task <IActionResult> GetTaxApplicability() { BaseResult <List <TaxApplicabilityViewModel> > taxApplicabilityResultFromCache = new BaseResult <List <TaxApplicabilityViewModel> >() { Result = RedisCacheHelper.Instance.Get <List <TaxApplicabilityViewModel> >(Constants.CacheKeys.TaxApplicabilityList) }; if (taxApplicabilityResultFromCache.Result == null || taxApplicabilityResultFromCache.Result.Count == 0) { BaseResult <List <TaxApplicability> > taxApplicabilityResult = await iPayment.GetTaxApplicability().ConfigureAwait(false); if (taxApplicabilityResult.IsError && taxApplicabilityResult.ExceptionMessage != null) { return(new StatusCodeResult(500)); } else if (taxApplicabilityResult.Result == null || taxApplicabilityResult.Result.Count == 0) { return(NoContent()); //204 } else { var result = PaymentDataResponseMapper.MapTaxApplicability(taxApplicabilityResult); RedisCacheHelper.Instance.Set <List <TaxApplicabilityViewModel> >(Constants.CacheKeys.TaxApplicabilityList, result.Result); return(Ok(result)); //200 } } return(Ok(taxApplicabilityResultFromCache)); //200 }
public async Task TestGetTaxApplicability_Positive_Predicate() { //Arrange var taxApplicability = new TaxApplicability() { Id = 1, Name = "Per Room", IsDeleted = false, NameItemId = 1 }; var baseResult = new BaseResult <List <TaxApplicability> >() { Result = new List <TaxApplicability>() { taxApplicability } }; var pred = new Func <TaxApplicability, bool>(x => x.IsDeleted == false); iTaxApplicabilityLibrary.Setup(x => x.GetListByPredicate(It.Is <Func <TaxApplicability, bool> >(y => y.GetType() == pred.GetType()))).Returns(Task.FromResult(baseResult)); //Act Task <BaseResult <List <TaxApplicability> > > result = paymentDataRepository.GetTaxApplicability(); //Assert Assert.IsTrue(result.Result != null); Assert.IsTrue(result.Result is BaseResult <List <TaxApplicability> >); }