AdvertiseArea.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using LotteryWebApp.Controllers;
  2. using LotteryWebApp.Service;
  3. using Microsoft.AspNetCore.Mvc;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Globalization;
  7. using System.Linq;
  8. using System.Threading.Tasks;
  9. namespace LotteryWebApp.Components
  10. {
  11. public class AdvertiseAreaModel
  12. {
  13. public List<Term> listTerm { get; set; }
  14. public long timeLeft { get; set; }
  15. public String timeExpired { get; set; }
  16. public String timeNow { get; set; }
  17. }
  18. public class AdvertiseArea : ViewComponent
  19. {
  20. APIFunctions api = new APIFunctions();
  21. public async Task<IViewComponentResult> InvokeAsync(List<Term> listTerm)
  22. {
  23. AdvertiseAreaModel model = new AdvertiseAreaModel();
  24. model.listTerm = listTerm;
  25. if (model.listTerm != null && model.listTerm.Count > 0)
  26. {
  27. model.timeLeft = BaseController.getCountTimeToTimestamp(model.listTerm[0].date_random);
  28. model.timeExpired = DateTime.ParseExact(model.listTerm[0].date_random, BaseController.formats, new CultureInfo("en-US"), DateTimeStyles.None).ToString("MM/dd/yyy HH:mm:ss");
  29. model.timeNow = DateTime.Now.ToString("MM/dd/yyy HH:mm:ss");
  30. }
  31. return View("AdvertiseArea", model);
  32. }
  33. }
  34. }