public string Moneda(string moneda) { var esvalido = Enum.TryParse(moneda.ToLower(), out Moneda eMoneda); if (esvalido) { switch (eMoneda) { case Common.Moneda.dolar: _cotizazcion = new Dolar(); break; case Common.Moneda.pesos: _cotizazcion = new Pesos(); break; case Common.Moneda.real: _cotizazcion = new Real(); break; } } else { return(string.Empty); } return(_cotizazcion.GetCotizacion()); }
/// <summary> /// Metodo que selecciona la Strategy y obtiene la cotizacion /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <CotizacionDto> GetResult(string id) { switch (id) { case DOLAR: this.cotizacion = new CotizacionDolar(this.httpClient); break; case EURO: this.cotizacion = new CotizacionEuro(this.httpClient); break; case REAL: this.cotizacion = new CotizacionReal(this.httpClient); break; default: throw new NotImplementedException("Moneda no implementada"); } return(await this.cotizacion?.GetCotizacion()); }
public HttpResponseMessage Get(string id) { ICotizacion cotizacion = null; switch (id.ToLower()) { case "dolar": cotizacion = new CotizacionDolar(); break; case "pesos": cotizacion = new CotizacionPesos(); break; case "real": cotizacion = new CotizacionReal(); break; } return(cotizacion.Ejecutar()); }
public Cotizacion(ICotizacion moneda) { this.moneda = moneda; }