Skip to content

Commit d485f4c

Browse files
committed
Merge pull request #3 from TimCostantino/master
Added: collection view, collections view, buckets view, and search
2 parents 81fb0c5 + d007674 commit d485f4c

File tree

10 files changed

+179
-8
lines changed

10 files changed

+179
-8
lines changed
Binary file not shown.
Binary file not shown.

StayWell.WebExample/Controllers/ExamplesController.cs

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@
1212
using StayWell.ServiceDefinitions.Buckets.Objects;
1313

1414
using StayWell.WebExample.Models;
15+
using StayWell.ServiceDefinitions.Collections.Objects;
1516

1617

1718
namespace StayWell.WebExample.Controllers
1819
{
1920
public class ExamplesController : Controller
2021
{
22+
private const int DEFAULT_COUNT = 50;
23+
2124
//Create an authenticated SW API client
2225
private ApiClient _client = new ApiClient(ConfigurationManager.AppSettings["ApplicationId"], ConfigurationManager.AppSettings["ApplicationSecret"]);
23-
private const int CONTENT_COUNT = 50;
26+
27+
#region Public Controller Actions
2428

2529
//
26-
// GET: /Samples/
30+
// GET: /Samples/DisplayContent
2731
public ActionResult DisplayContent()
2832
{
2933
//Request the specific article. If you intend to display the full article you must send the flag "IncludeBody"
@@ -36,7 +40,7 @@ public ActionResult DisplayContent()
3640
}
3741

3842
//
39-
// GET: /Samples/
43+
// GET: /Samples/DisplayRelatedContent
4044
public ActionResult DisplayRelatedContent()
4145
{
4246
RelatedContentModel model = new RelatedContentModel
@@ -48,6 +52,63 @@ public ActionResult DisplayRelatedContent()
4852
return View(model);
4953
}
5054

55+
//
56+
// GET: /Samples/DisplayCollection
57+
public ActionResult DisplayCollection()
58+
{
59+
CollectionResponse collection = _client.Collections.GetCollection("development-sample-license",true,true,true);
60+
61+
return View(collection);
62+
}
63+
64+
//
65+
// GET: /Samples/DisplayCollections
66+
public ActionResult DisplayCollections()
67+
{
68+
CollectionListResponse collections = _client.Collections.SearchCollections(new CollectionSearchRequest
69+
{
70+
Count = DEFAULT_COUNT
71+
});
72+
73+
return View(collections);
74+
75+
}
76+
77+
//
78+
// GET: /Samples/DisplayBuckets
79+
public ActionResult DisplayBuckets()
80+
{
81+
ContentBucketList buckets = _client.Buckets.SearchBuckets(new BucketSearchRequest
82+
{
83+
Count = DEFAULT_COUNT
84+
});
85+
86+
return View(buckets);
87+
}
88+
89+
//
90+
// GET: /Samples/SearchContent
91+
public ActionResult SearchContent(string searchString)
92+
{
93+
ContentList searchResults = new ContentList();
94+
95+
if (!string.IsNullOrEmpty(searchString))
96+
{
97+
searchResults = _client.Content.SearchContent(new ContentSearchRequest
98+
{
99+
Count = DEFAULT_COUNT,
100+
Query = searchString
101+
102+
});
103+
}
104+
105+
return View(searchResults);
106+
}
107+
108+
109+
#endregion
110+
111+
#region Private Helper Methods
51112

52113
private List<ContentResponse> GetRelatedContent(string bucketSlug, string contentSlug)
53114
{
@@ -70,7 +131,7 @@ private List<ContentResponse> GetRelatedContent(string bucketSlug, string conten
70131
ContentList relatedContent = _client.Content.SearchContent(new ContentSearchRequest
71132
{
72133
Query = query,
73-
Count = CONTENT_COUNT
134+
Count = DEFAULT_COUNT
74135
});
75136

76137
//Fiter out the item that we started the related to search from.
@@ -85,5 +146,7 @@ private List<ContentResponse> GetRelatedContent(string bucketSlug, string conten
85146

86147
return contentResponses;
87148
}
88-
}
149+
150+
#endregion
151+
}
89152
}

StayWell.WebExample/StayWell.WebExample.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@
138138
<Content Include="Scripts\respond.js" />
139139
<Content Include="Scripts\respond.min.js" />
140140
<Content Include="Scripts\_references.js" />
141-
<Content Include="Web.config" />
141+
<Content Include="Web.config">
142+
<SubType>Designer</SubType>
143+
</Content>
142144
<Content Include="Web.Debug.config">
143145
<DependentUpon>Web.config</DependentUpon>
144146
</Content>
@@ -155,6 +157,10 @@
155157
<Content Include="Scripts\jquery-1.10.2.min.map" />
156158
<Content Include="Views\Examples\DisplayContent.cshtml" />
157159
<Content Include="Views\Examples\DisplayRelatedContent.cshtml" />
160+
<Content Include="Views\Examples\DisplayCollection.cshtml" />
161+
<Content Include="Views\Examples\SearchContent.cshtml" />
162+
<Content Include="Views\Examples\DisplayCollections.cshtml" />
163+
<Content Include="Views\Examples\DisplayBuckets.cshtml" />
158164
</ItemGroup>
159165
<ItemGroup>
160166
<ProjectReference Include="..\StayWell.ClientFramework\StayWell.ClientFramework.csproj">
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@using StayWell.ServiceDefinitions.Buckets.Objects
2+
@using StayWell.WebExample.Models
3+
4+
@model ContentBucketList
5+
@{
6+
ViewBag.Title = "Display Buckets";
7+
}
8+
9+
<h2>Display Buckets</h2>
10+
<ul>
11+
@foreach (ContentBucketResponse item in Model.Items)
12+
{
13+
<li>@item.Name</li>
14+
}
15+
</ul>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@using StayWell.ServiceDefinitions.Collections.Objects
2+
@using StayWell.WebExample.Models
3+
4+
@model CollectionResponse
5+
@helper TreeView(List<CollectionItemResponse> items)
6+
{
7+
foreach (var item in items)
8+
{
9+
<li>
10+
@if (item.Items==null || item.Items.Count == 0)
11+
{
12+
<span>@item.Title</span>
13+
}
14+
else
15+
{
16+
<span>@item.Title</span>
17+
<ul>
18+
@TreeView(item.Items)
19+
</ul>
20+
}
21+
</li>
22+
}
23+
}
24+
@{
25+
ViewBag.Title = "Display Collection";
26+
}
27+
28+
<h2>Display Collection</h2>
29+
30+
<ul>
31+
@TreeView(Model.Items)
32+
</ul>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@using StayWell.ServiceDefinitions.Collections.Objects
2+
@using StayWell.WebExample.Models
3+
4+
@model CollectionListResponse
5+
@{
6+
ViewBag.Title = "DisplayCollections";
7+
}
8+
9+
<h2>Display Collections</h2>
10+
<ul>
11+
@foreach (CollectionResponse item in Model.Items)
12+
{
13+
<li>@item.Title</li>
14+
}
15+
</ul>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@using StayWell.ServiceDefinitions.Content.Objects
2+
@using StayWell.WebExample.Models
3+
@model ContentList
4+
5+
@{
6+
ViewBag.Title = "SearchContent";
7+
}
8+
9+
<h2>Search Content</h2>
10+
11+
@using (Html.BeginForm())
12+
{
13+
<p>
14+
Search: @Html.TextBox("SearchString") <input type="submit" value="Filter" />
15+
</p>
16+
}
17+
18+
@if (Model.Items != null)
19+
{
20+
<hr />
21+
<h4>Search Results</h4>
22+
<ul>
23+
@foreach (ContentResponse item in Model.Items)
24+
{
25+
<li>@item.Title</li>
26+
}
27+
</ul>
28+
}

StayWell.WebExample/Views/Shared/_Layout.cshtml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121
<div class="navbar-collapse collapse">
2222
<ul class="nav navbar-nav">
2323
<li>@Html.ActionLink("Home", "Index", "Home")</li>
24-
<li>@Html.ActionLink("Display Content", "DisplayContent", "Examples")</li>
25-
<li>@Html.ActionLink("Display Related", "DisplayRelatedContent", "Examples")</li>
24+
<li>@Html.ActionLink("Article", "DisplayContent", "Examples")</li>
25+
<li>@Html.ActionLink("Related", "DisplayRelatedContent", "Examples")</li>
26+
<li>@Html.ActionLink("Collection", "DisplayCollection", "Examples")</li>
27+
<li>@Html.ActionLink("Collections", "DisplayCollections", "Examples")</li>
28+
<li>@Html.ActionLink("Buckets", "DisplayBuckets", "Examples")</li>
29+
<li>@Html.ActionLink("Search", "SearchContent", "Examples")</li>
2630
</ul>
2731
</div>
2832
</div>

StayWell.WebExample/Web.config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,12 @@
4545
</dependentAssembly>
4646
</assemblyBinding>
4747
</runtime>
48+
<!--<system.net>
49+
<defaultProxy>
50+
<proxy
51+
usesystemdefault="False"
52+
bypassonlocal="True"
53+
proxyaddress="http://127.0.0.1:8888"/>
54+
</defaultProxy>
55+
</system.net>-->
4856
</configuration>

0 commit comments

Comments
 (0)