added statistics page

This commit is contained in:
Nicolas Constant 2020-12-30 01:58:08 -05:00
parent 4b05123bd3
commit 3844420476
No known key found for this signature in database
GPG key ID: 1E9F677FB01A5688
3 changed files with 54 additions and 0 deletions

View 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);
}
}
}

View file

@ -0,0 +1,8 @@
namespace BirdsiteLive.Models.StatisticsModels
{
public class Statistics
{
public int FollowersCount { get; set; }
public int TwitterUserCount { get; set; }
}
}

View 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>