added statistics page
This commit is contained in:
parent
4b05123bd3
commit
3844420476
3 changed files with 54 additions and 0 deletions
34
src/BirdsiteLive/Controllers/StatisticsController.cs
Normal file
34
src/BirdsiteLive/Controllers/StatisticsController.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BirdsiteLive.DAL.Contracts;
|
||||
using BirdsiteLive.Models.StatisticsModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BirdsiteLive.Controllers
|
||||
{
|
||||
public class StatisticsController : Controller
|
||||
{
|
||||
private readonly ITwitterUserDal _twitterUserDal;
|
||||
private readonly IFollowersDal _followersDal;
|
||||
|
||||
#region Ctor
|
||||
public StatisticsController(ITwitterUserDal twitterUserDal, IFollowersDal followersDal)
|
||||
{
|
||||
_twitterUserDal = twitterUserDal;
|
||||
_followersDal = followersDal;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var stats = new Statistics
|
||||
{
|
||||
FollowersCount = await _followersDal.GetFollowersCountAsync(),
|
||||
TwitterUserCount = await _twitterUserDal.GetTwitterUsersCountAsync()
|
||||
};
|
||||
return View(stats);
|
||||
}
|
||||
}
|
||||
}
|
8
src/BirdsiteLive/Models/StatisticsModels/Statistics.cs
Normal file
8
src/BirdsiteLive/Models/StatisticsModels/Statistics.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace BirdsiteLive.Models.StatisticsModels
|
||||
{
|
||||
public class Statistics
|
||||
{
|
||||
public int FollowersCount { get; set; }
|
||||
public int TwitterUserCount { get; set; }
|
||||
}
|
||||
}
|
12
src/BirdsiteLive/Views/Statistics/Index.cshtml
Normal file
12
src/BirdsiteLive/Views/Statistics/Index.cshtml
Normal file
|
@ -0,0 +1,12 @@
|
|||
@model BirdsiteLive.Models.StatisticsModels.Statistics
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Statistics";
|
||||
}
|
||||
|
||||
<h2>Statistics</h2>
|
||||
|
||||
<ul>
|
||||
<li>Twitter Users: @Model.TwitterUserCount</li>
|
||||
<li>Followers: @Model.FollowersCount</li>
|
||||
</ul>
|
Reference in a new issue