public async Task TestGetCurrencyByHotelId_Positive_Success() { //Arrange int hotelId = 5; var currency = new Currency() { Id = 1, Name = "RS", IsActive = true, Code = "IND", IsDeleted = false }; var baseResult = new BaseResult <List <Currency> >() { Result = new List <Currency>() { currency } }; iCurrencyConnectionLibrary.Setup(x => x.ExecuteStoredProcedure(It.IsAny <string>(), It.IsAny <DynamicParameters>())).Returns(Task.FromResult(baseResult)); //Act Task <BaseResult <List <Currency> > > result = paymentDataRepository.GetCurrencyByHotelId(hotelId); //Assert Assert.IsTrue(result.Result != null); Assert.IsTrue(result.Result is BaseResult <List <Currency> >); }
public async Task <IActionResult> GetCurrencyByHotelId([FromBody] int hotelId) { BaseResult <List <Currency> > currencyResult = new BaseResult <List <Currency> >(); if (hotelId <= default(int)) { currencyResult.IsError = true; currencyResult.Message = "Invalid Hotel Id"; return(BadRequest(currencyResult)); } currencyResult = await iPayment.GetCurrencyByHotelId(hotelId).ConfigureAwait(false); if (currencyResult.IsError && currencyResult.ExceptionMessage != null) { return(new StatusCodeResult(500)); } else if (currencyResult.Result == null || currencyResult.Result.Count == 0) { return(NoContent()); //204 } var result = PaymentDataResponseMapper.MapCurrency(currencyResult); return(Ok(result)); //200 }