FinancialController.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using Microsoft.AspNetCore.Mvc;
  2. using economy.Models;
  3. using economy.Models.Financial;
  4. using Exchange = economy.Models.Financial.Exchange;
  5. using Interest = economy.Models.Financial.Interest;
  6. using International = economy.Models.Financial.International;
  7. namespace economy.Controllers
  8. {
  9. public class FinancialController : Controller
  10. {
  11. private readonly KoreaEximGoKR _koreaEximGoKR;
  12. private Dictionary<string, string> _queryString;
  13. public FinancialController(KoreaEximGoKR koreaEximGoKR)
  14. {
  15. _koreaEximGoKR = koreaEximGoKR;
  16. }
  17. // 환율
  18. public async Task<IActionResult> Exchange(Exchange.Request request)
  19. {
  20. if (!ModelState.IsValid)
  21. {
  22. return BadRequest(ModelState);
  23. }
  24. FinancialModel exchange = new FinancialModel(_koreaEximGoKR);
  25. Exchange.Response itemList = await exchange.GetExchange(request);
  26. var viewModel = new View<Exchange.Request, Exchange.Response>();
  27. viewModel.Request = request;
  28. viewModel.Response = itemList;
  29. await exchange.GetExchangeValue();
  30. return View(viewModel);
  31. }
  32. // 대출 금리
  33. public async Task<IActionResult> Interest(Interest.Request request)
  34. {
  35. if (!ModelState.IsValid)
  36. {
  37. return BadRequest(ModelState);
  38. }
  39. FinancialModel interest = new FinancialModel(_koreaEximGoKR);
  40. Interest.Response itemList = await interest.GetInterestRate(request);
  41. var viewModel = new View<Interest.Request, Interest.Response>();
  42. viewModel.Request = request;
  43. viewModel.Response = itemList;
  44. ViewData["type"] = "Interest";
  45. return View(viewModel);
  46. }
  47. // 국제 금리
  48. public async Task<IActionResult> International(International.Request request)
  49. {
  50. if (!ModelState.IsValid)
  51. {
  52. return BadRequest(ModelState);
  53. }
  54. FinancialModel international = new FinancialModel(_koreaEximGoKR);
  55. International.Response itemList = await international.GetInternationalRate(request);
  56. var viewModel = new View<International.Request, International.Response>();
  57. viewModel.Request = request;
  58. viewModel.Response = itemList;
  59. ViewData["type"] = "International";
  60. return View(viewModel);
  61. }
  62. }
  63. }