Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
guru
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
guru
Commits
352b90cc
Commit
352b90cc
authored
6 years ago
by
Clint Mourlevat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding display price from coinmarket API
parent
5542d755
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
+23
-5
HomeController.cs
Controllers/HomeController.cs
+19
-1
TickerService.cs
Services/TickerService.cs
+1
-2
Index.cshtml
Views/Home/Index.cshtml
+3
-2
No files found.
Controllers/HomeController.cs
View file @
352b90cc
...
...
@@ -8,7 +8,9 @@ using System.IO;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.Extensions.Caching.Memory
;
using
NBitcoin
;
using
Newtonsoft.Json
;
using
QRCoder
;
using
Stratis.Bitcoin.Networks
;
...
...
@@ -16,9 +18,20 @@ namespace Stratis.Guru.Controllers
{
public
class
HomeController
:
Controller
{
private
IMemoryCache
_memoryCache
;
public
HomeController
(
IMemoryCache
memoryCache
)
{
_memoryCache
=
memoryCache
;
}
public
IActionResult
Index
()
{
return
View
();
dynamic
coinmarketcap
=
JsonConvert
.
DeserializeObject
(
_memoryCache
.
Get
(
"Coinmarketcap"
).
ToString
());
return
View
(
new
Ticker
()
{
UsdPrice
=
coinmarketcap
.
data
.
quotes
.
USD
.
price
});
}
[
Route
(
"about"
)]
...
...
@@ -62,6 +75,11 @@ namespace Stratis.Guru.Controllers
}
}
public
class
Ticker
{
public
double
UsdPrice
{
get
;
set
;
}
}
public
class
StratisAddressPayload
{
public
string
PrivateKey
{
get
;
set
;
}
...
...
This diff is collapsed.
Click to expand it.
Services/TickerService.cs
View file @
352b90cc
...
...
@@ -23,11 +23,10 @@ namespace Stratis.Guru.Services
updateTimer
.
Interval
=
10000
;
updateTimer
.
Elapsed
+=
(
sender
,
args
)
=>
{
var
coinmarketCapApiClient
=
new
Rest
Sharp
.
Rest
Client
(
"https://api.coinmarketcap.com/v2/ticker/1343/"
);
var
coinmarketCapApiClient
=
new
RestClient
(
"https://api.coinmarketcap.com/v2/ticker/1343/"
);
var
coinmarketCapApiRequest
=
new
RestRequest
(
Method
.
GET
);
var
coinmarketcapApi
=
coinmarketCapApiClient
.
Execute
(
coinmarketCapApiRequest
);
_memoryCache
.
Set
(
"Coinmarketcap"
,
coinmarketcapApi
.
Content
);
//dynamic resultAPI = JsonConvert.DeserializeObject(coinmarketcapAPI.Content);
};
updateTimer
.
Start
();
return
Task
.
CompletedTask
;
...
...
This diff is collapsed.
Click to expand it.
Views/Home/Index.cshtml
View file @
352b90cc
@{
@model Stratis.Guru.Controllers.Ticker
@{
ViewBag.Title = "Online ticker for Stratis";
ViewData["Title"] = "Home Page";
}
...
...
@@ -12,7 +13,7 @@
<div>
<span class="click-edit">1 STRAT</span> =
</div>
<span class="display-1 font-weight-bold">@(
2
.ToString("C2"))</span>
<span class="display-1 font-weight-bold">@(
Model.UsdPrice
.ToString("C2"))</span>
</h1>
<a href="#" class="btn-secondary-box">Download Whitepaper</a>
</div>
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment