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: 5 additions & 5 deletions ProjectHackton/TestBestHack/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ namespace TestBestHack.Controllers
public class HomeController : Controller
{

public RootObject GetData(string category)
public async Task<RootObject> GetData(string category)
{
WebRequest request = WebRequest.Create(@"https://newsapi.org/v1/sources?category=" + category + "&language=en");

request.Method = "GET";
request.ContentType = "application/json";

WebResponse response = request.GetResponse();
WebResponse response = await request.GetResponseAsync();

string answer = String.Empty;
string answer;

using (Stream stream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream))
{
answer = reader.ReadToEnd();
answer = await reader.ReadToEndAsync();
}
}

Expand Down Expand Up @@ -78,4 +78,4 @@ public ActionResult Index()
return View(sources);
}
}
}
}
19 changes: 10 additions & 9 deletions ProjectHackton/TestBestHack/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script>
$(()=>{
$('th:odd').css('background-color','green');
$('#changecolor').click(()=>{
$('th:even').css('background-color','green');
$('th:odd').css('background-color','white');
});
});
</script>
<h2 style="text-align:center">News List</h2>
@Html.Partial("~/Views/Home/Select.cshtml",new TestBestHack.Models.Source())
<br />
Expand Down Expand Up @@ -50,11 +59,3 @@

</table>

<ul class="list-group">
@foreach (var item in Model) {
<li class="list-group-item justify-content-between">
@Html.DisplayFor(modelItem => item.name)
<span class="badge badge-default badge-pill">@Html.DisplayFor(modelItem => item.country)</span>
</li>
}
</ul>