EUExchangeRateController.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using Microsoft.AspNetCore.Mvc;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using XYY.Common.Standard;
  7. using XYY.Core.Standard.Mvc;
  8. using XYY.Service.Standard.Finance;
  9. namespace XYY.Api.Finance.Controllers
  10. {
  11. [Route("api/[controller]/[action]")]
  12. [ApiController]
  13. public class EUExchangeRateController : ApiControllerBase
  14. {
  15. public class RateDto
  16. {
  17. public DateTime StartTime { get; set; }
  18. public DateTime EndTime { get; set; }
  19. public byte[] file
  20. {
  21. get
  22. {
  23. return new System.Net.WebClient().DownloadData(Url);
  24. }
  25. }
  26. public int Id { get; set; }
  27. public string Url
  28. {
  29. get; set;
  30. }
  31. }
  32. IEUExchangeRateService EUExchangeRateService;
  33. public EUExchangeRateController(IEUExchangeRateService eUExchangeRateService)
  34. {
  35. EUExchangeRateService = eUExchangeRateService;
  36. }
  37. public async Task<IActionResult> AddEUExchangeRate(RateDto dto)
  38. {
  39. await EUExchangeRateService.AddEUExchangeRate(dto.StartTime, dto.EndTime, dto.file);
  40. return Ok();
  41. }
  42. public async Task<IActionResult> ChangeEUExchangeRate(RateDto dto)
  43. {
  44. await EUExchangeRateService.ChangeEUExchangeRate(new Model.Standard.Finance.Finance_EUExchangeRate { Id = dto.Id, StartTime = dto.StartTime, EndTime = dto.EndTime });
  45. return Ok();
  46. }
  47. public async Task<IActionResult> ChangeEUExchangeDetail(RateDto dto)
  48. {
  49. await EUExchangeRateService.ChangeEUExchangeDetail(dto.Id, dto.file);
  50. return Ok();
  51. }
  52. public async Task<IActionResult> GetPageResult(QueryModel queryModel)
  53. {
  54. var result = await EUExchangeRateService.GetPageResult(queryModel);
  55. return Ok(result);
  56. }
  57. public async Task<IActionResult> GetList(int Id)
  58. {
  59. var result = await EUExchangeRateService.GetList(Id);
  60. return Ok(result);
  61. }
  62. }
  63. }