Changeset 138874f56881…
Parent 490adac41f40…
by Clayton Miller <clayton.miller@nexportengineering.com>
Changes to 26 files · Browse files at 138874f56881 Showing diff from parent 490adac41f40 Diff from another changeset...
|
|
|
|
|
|
|
|
@@ -1,5 +1,4 @@ using System;
-using System.Collections;
using System.Collections.Generic;
namespace NexportWebApiDemo.ApiModels.v1
@@ -31,14 +30,12 @@ public class CatalogRequest
{
public Guid group_id { get; set; }
- public int availability { get; set; }
public int publishing_model { get; set; }
}
public class CatalogResponse
{
- public IList<Guid> catalogs { get; set; }
- public Guid id { get; set; }
+ public IList<CatalogResponseItem> catalogs { get; set; }
}
public class CatalogResponseItem
|
@@ -1,5 +1,5 @@ using System;
-using System.Collections.Generic;
+using System.Linq;
using System.Web.Mvc;
using NexportWebApiDemo.ApiModels.v1;
using NexportWebApiDemoClient;
@@ -22,16 +22,11 @@ var catRequest = new CatalogRequest()
{
group_id = new Guid("ed5ba4ac-73e4-4e64-837f-b26cb8ef3c4b"),
- availability = 2,
publishing_model = 0
};
- var catResponse = WebApiRequests.GetCatalogIds(catRequest, authToken.access_token);
- var catalogs = new List<CatalogResponseItem>();
- for (var i = 0; i < 30; i++)
- {
- catalogs.Add(WebApiRequests.GetCatalog(catResponse.catalogs[i], authToken.access_token));
- }
+ var catResponse = WebApiRequests.GetCatalogs(catRequest, authToken.access_token);
+ var catalogs = catResponse.catalogs.ToList();
ViewBag.Catalogs = catalogs;
return View();
}
|
|
|
@@ -75,7 +75,7 @@
<div class="col-md-9">
<div class="row">
- <table class="table">
+ <table class="table table-striped">
<thead>
<tr>
<th>Catalog</th>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -40,13 +40,12 @@ var catalogRequest = new CatalogRequest()
{
group_id = new Guid("f60904d7-0164-41cc-a246-46aa21a49af9"),
- availability = 2,
publishing_model = 1
};
- var getCatalogIdsResponse = WebApiRequests.GetCatalogIds(catalogRequest, accessToken);
+ var getCatalogResponse = WebApiRequests.GetCatalogs(catalogRequest, accessToken);
- Console.WriteLine(getCatalogIdsResponse.catalogs);
+ Console.WriteLine(getCatalogResponse.catalogs);
}
}
}
|
@@ -1,23 +1,18 @@ using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Text;
-using System.Threading.Tasks;
using NexportWebApiDemo.ApiModels.v1;
namespace NexportWebApiDemoClient
{
public class WebApiRequests
{
- private static string BaseUri = "http://local.nexportcampus.com/api/v1/";
+ private const string BaseUri = "http://local.nexportcampus.com/api/v1/";
public static WAAuthenticationTokenResponse Authenticate(WAAuthTokenRequest request)
{
using (var client = new HttpClient())
{
- var requestUri = BaseUri + "AdminApi/Authenticate";
+ const string requestUri = BaseUri + "AdminApi/Authenticate";
var response = client.PostAsJsonAsync(requestUri, request).Result;
//TODO Check return status
@@ -36,11 +31,11 @@ }
}
- public static CatalogResponse GetCatalogIds(CatalogRequest request, Guid accessToken, int page = 1, int perPage = 30)
+ public static CatalogResponse GetCatalogs(CatalogRequest request, Guid accessToken, int page = 1, int perPage = 30)
{
using (var client = new HttpClient())
{
- var requestUri = BaseUri + "LearningApi/GetCatalogIds?access_token=" + accessToken + "&page=" + page +
+ var requestUri = BaseUri + "LearningApi/GetCatalogs?access_token=" + accessToken + "&page=" + page +
"&per_page=" + perPage;
var response = client.PostAsJsonAsync(requestUri, request).Result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Loading...