Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. [HttpPost]
  2. public void SetTheme(string data)
  3. {
  4. HttpCookie cookie = new HttpCookie("theme");
  5. cookie.Value = data;
  6. cookie.Expires = DateTime.Now.AddDays(1);
  7. Response.Cookies.Add(cookie);
  8. }
  9.  
  10. [HttpPost]
  11. public void ChangeLanguage(string data)
  12. {
  13. HttpCookie cookie = new HttpCookie("language");
  14. cookie.Value = data;
  15. cookie.Expires = DateTime.Now.AddDays(1);
  16. Response.Cookies.Add(cookie);
  17. }
  18.  
  19. [HttpPost]
  20. public async Task SetCurrency(string code)
  21. {
  22. HttpCookie cookie = new HttpCookie("currency");
  23. if (code == "pln")
  24. {
  25. cookie.Values.Add("name", "złotówka");
  26. cookie.Values.Add("code", "pln");
  27. cookie.Values.Add("value", "1");
  28. }
  29. else
  30. {
  31. CurrencyClient client = new CurrencyClient();
  32. CurrencyObject currency = await client.GetCurrencyAsync("a", code);
  33. cookie.Values.Add("name", currency.Currency);
  34. cookie.Values.Add("code", currency.Code);
  35. cookie.Values.Add("value", currency.Rates[0].Mid.ToString());
  36. }
  37. cookie.Expires = DateTime.Now.AddDays(1);
  38. Response.Cookies.Add(cookie);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement