public async Task <Models.ExhangeRateModel> GetExchangeRate(Models.ExchangeRateRequestModel model) { try { using (var context = dBContext) { var q = (from p in context.tblExchangeRates where p.Source == model.Source && p.Target == model.Target select new Models.ExhangeRateModel { Value = p.Value, Source = p.Source, Target = p.Target } ).ToList().FirstOrDefault(); return(await Task.Factory.StartNew(() => { return q; })); } } catch (Exception ex) { throw ex; } }
public async Task <Models.ExhangeRateModel> GetExchangeRate(Models.ExchangeRateRequestModel model) { return(await this._repository.GetExchangeRate(model)); }
public async Task <Models.ResponseModelBase <Models.ExhangeRateModel> > GetExchange([FromBody] Models.ExchangeRateRequestModel model) { try { var response = await _bsvc.GetExchangeRate(model); response.TargetValue = (Convert.ToDecimal(response.Value) * Convert.ToDecimal(model.SourceValue)).ToString(); return(await Task.Factory.StartNew(() => { return new Models.ResponseModelBase <Models.ExhangeRateModel>() { Success = true, Data = response }; })); } catch (Exception ex) { return(await Task.Factory.StartNew(() => { return new Models.ResponseModelBase <Models.ExhangeRateModel>() { Success = false, Message = ex.Message }; })); } }