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
Oct 17, 2018
by
Clint Mourlevat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding display price from coinmarket API
parent
5542d755
Hide 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;
...
@@ -8,7 +8,9 @@ using System.IO;
using
System.Linq
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.Extensions.Caching.Memory
;
using
NBitcoin
;
using
NBitcoin
;
using
Newtonsoft.Json
;
using
QRCoder
;
using
QRCoder
;
using
Stratis.Bitcoin.Networks
;
using
Stratis.Bitcoin.Networks
;
...
@@ -16,9 +18,20 @@ namespace Stratis.Guru.Controllers
...
@@ -16,9 +18,20 @@ namespace Stratis.Guru.Controllers
{
{
public
class
HomeController
:
Controller
public
class
HomeController
:
Controller
{
{
private
IMemoryCache
_memoryCache
;
public
HomeController
(
IMemoryCache
memoryCache
)
{
_memoryCache
=
memoryCache
;
}
public
IActionResult
Index
()
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"
)]
[
Route
(
"about"
)]
...
@@ -62,6 +75,11 @@ namespace Stratis.Guru.Controllers
...
@@ -62,6 +75,11 @@ namespace Stratis.Guru.Controllers
}
}
}
}
public
class
Ticker
{
public
double
UsdPrice
{
get
;
set
;
}
}
public
class
StratisAddressPayload
public
class
StratisAddressPayload
{
{
public
string
PrivateKey
{
get
;
set
;
}
public
string
PrivateKey
{
get
;
set
;
}
...
...
Services/TickerService.cs
View file @
352b90cc
...
@@ -23,11 +23,10 @@ namespace Stratis.Guru.Services
...
@@ -23,11 +23,10 @@ namespace Stratis.Guru.Services
updateTimer
.
Interval
=
10000
;
updateTimer
.
Interval
=
10000
;
updateTimer
.
Elapsed
+=
(
sender
,
args
)
=>
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
coinmarketCapApiRequest
=
new
RestRequest
(
Method
.
GET
);
var
coinmarketcapApi
=
coinmarketCapApiClient
.
Execute
(
coinmarketCapApiRequest
);
var
coinmarketcapApi
=
coinmarketCapApiClient
.
Execute
(
coinmarketCapApiRequest
);
_memoryCache
.
Set
(
"Coinmarketcap"
,
coinmarketcapApi
.
Content
);
_memoryCache
.
Set
(
"Coinmarketcap"
,
coinmarketcapApi
.
Content
);
//dynamic resultAPI = JsonConvert.DeserializeObject(coinmarketcapAPI.Content);
};
};
updateTimer
.
Start
();
updateTimer
.
Start
();
return
Task
.
CompletedTask
;
return
Task
.
CompletedTask
;
...
...
Views/Home/Index.cshtml
View file @
352b90cc
@{
@model Stratis.Guru.Controllers.Ticker
@{
ViewBag.Title = "Online ticker for Stratis";
ViewBag.Title = "Online ticker for Stratis";
ViewData["Title"] = "Home Page";
ViewData["Title"] = "Home Page";
}
}
...
@@ -12,7 +13,7 @@
...
@@ -12,7 +13,7 @@
<div>
<div>
<span class="click-edit">1 STRAT</span> =
<span class="click-edit">1 STRAT</span> =
</div>
</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>
</h1>
<a href="#" class="btn-secondary-box">Download Whitepaper</a>
<a href="#" class="btn-secondary-box">Download Whitepaper</a>
</div>
</div>
...
...
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