Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions GradDemo.Api/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using GradDemo.Api.Entities;
using GradDemo.Api.Helpers;
using GradDemo.Api.Models;
using GradDemo.Api.Models.Auth;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -22,6 +23,7 @@ public AuthController(UserManager<Device> userManager, AuthTokenHelper authhelpe
{
_userManager = userManager;
_authHelper = authhelper;

}

/// <summary>
Expand Down Expand Up @@ -89,5 +91,13 @@ private string GenerateRandomClientSecret()
return converted;
}
}

/*[HttpGet("preferences")]
/*public async Task<Response<Device>> GetPreference()
{
var preference = new Device();

//var pref = await _userManager.GetPreferences();
}*/
}
}
12 changes: 12 additions & 0 deletions GradDemo.Api/Controllers/CryptoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,17 @@ public async Task<Response<CryptoCoinResponse>> GetCoin(string coinId, string cu

return Response<CryptoCoinResponse>.Error("Something went wrong");
}

[HttpGet("value/for/currencies")]
public async Task<Response<string[]>> GetCurrencyPrice()
{
string[] currencyResults; //will return an array of strings, in this case, a string of the different currencies
currencyResults = await _coinGeckoProvider.GetCurrency(); // awaits the class written in the GeckoProvider
if (currencyResults != null) //if currencyResults are not empty, then return a string array of all currencies else state that there is an error message
{
return Response<string[]>.Successful(currencyResults);
}
return Response<string[]>.Error("Something went wrong");
}
}
}
88 changes: 0 additions & 88 deletions GradDemo.Api/Controllers/DemoController.cs

This file was deleted.

1 change: 1 addition & 0 deletions GradDemo.Api/Entities/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ namespace GradDemo.Api.Entities
public class Device : IdentityUser
{
public string ShirtSize { get; set; }
public string Preference { get; set; }
}
}
19 changes: 19 additions & 0 deletions GradDemo.Api/Models/Crypto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace GradDemo.Api.Models
{
public class Crypto
{

public class CryptoCurrency
{
public int Id { set; get; }
public int Name { set; get; }
public int Current_price { set; get; }

}
}
}
16 changes: 16 additions & 0 deletions GradDemo.Api/Providers/CoinGeckoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,21 @@ public CoinGeckoProvider(string baseUrl)

return null;
}
public async Task<string[]> GetCurrency()
{
string[] currencyResults = null;
string path = $"/api/v3/simple/supported_vs_currencies";

HttpResponseMessage currencyResponse = await client.GetAsync(path);

if (currencyResponse.IsSuccessStatusCode)
{
var result = await currencyResponse.Content.ReadAsStringAsync();
var currencyResult = JsonConvert.DeserializeObject<string[]>(result);
currencyResults = currencyResult;
return currencyResults;
}
return null;
}
}
}
Binary file not shown.
3 changes: 3 additions & 0 deletions GradDemo.Api/node_modules/coingecko-api/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions GradDemo.Api/node_modules/coingecko-api/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading