|
|
|
@ -46,95 +46,6 @@ namespace Teknik.Areas.Stats.Controllers
@@ -46,95 +46,6 @@ namespace Teknik.Areas.Stats.Controllers
|
|
|
|
|
model.VaultCount = _dbContext.Vaults.Count(); |
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// Get Transaction Inforomation
|
|
|
|
|
#region Transactions
|
|
|
|
|
DateTime curTime = DateTime.Now; |
|
|
|
|
|
|
|
|
|
var billSums = _dbContext.Transactions.OfType<Bill>().GroupBy(b => new { b.Currency, b.DateSent.Month, b.DateSent.Year }).Select(b => new { month = b.Key.Month, year = b.Key.Year, currency = b.Key.Currency, total = b.Sum(c => c.Amount) }).ToList(); |
|
|
|
|
foreach (var sum in billSums) |
|
|
|
|
{ |
|
|
|
|
decimal exchangeRate = CurrencyHelper.GetExchangeRate(sum.currency); |
|
|
|
|
decimal realValue = sum.total * exchangeRate; |
|
|
|
|
model.Transactions.TotalBills += realValue; |
|
|
|
|
model.Transactions.TotalNet += realValue; |
|
|
|
|
if (curTime.Month == sum.month && curTime.Year == sum.year) |
|
|
|
|
{ |
|
|
|
|
model.Transactions.CurrentMonthBills += Math.Abs(realValue); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var oneSums = _dbContext.Transactions.OfType<OneTime>().GroupBy(b => new { b.Currency, b.DateSent.Month, b.DateSent.Year }).Select(b => new { month = b.Key.Month, year = b.Key.Year, currency = b.Key.Currency, total = b.Sum(c => c.Amount) }).ToList(); |
|
|
|
|
foreach (var sum in oneSums) |
|
|
|
|
{ |
|
|
|
|
decimal exchangeRate = CurrencyHelper.GetExchangeRate(sum.currency); |
|
|
|
|
decimal realValue = sum.total * exchangeRate; |
|
|
|
|
model.Transactions.TotalOneTimes += realValue; |
|
|
|
|
model.Transactions.TotalNet += realValue; |
|
|
|
|
if (curTime.Month == sum.month && curTime.Year == sum.year) |
|
|
|
|
{ |
|
|
|
|
model.Transactions.CurrentMonthBills += Math.Abs(realValue); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var donationSums = _dbContext.Transactions.OfType<Donation>().GroupBy(b => new { b.Currency, b.DateSent.Month, b.DateSent.Year }).Select(b => new { month = b.Key.Month, year = b.Key.Year, currency = b.Key.Currency, total = b.Sum(c => c.Amount) }).ToList(); |
|
|
|
|
foreach (var sum in donationSums) |
|
|
|
|
{ |
|
|
|
|
decimal exchangeRate = CurrencyHelper.GetExchangeRate(sum.currency); |
|
|
|
|
decimal realValue = sum.total * exchangeRate; |
|
|
|
|
model.Transactions.TotalDonations += realValue; |
|
|
|
|
model.Transactions.TotalNet += realValue; |
|
|
|
|
if (curTime.Month == sum.month && curTime.Year == sum.year) |
|
|
|
|
{ |
|
|
|
|
model.Transactions.CurrentMonthIncome += Math.Abs(realValue); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Bill> bills = _dbContext.Transactions.OfType<Bill>().OrderByDescending(b => b.DateSent).ToList(); |
|
|
|
|
if (bills != null) |
|
|
|
|
{ |
|
|
|
|
foreach (Bill bill in bills) |
|
|
|
|
{ |
|
|
|
|
BillViewModel billModel = new BillViewModel(); |
|
|
|
|
billModel.Amount = bill.Amount; |
|
|
|
|
billModel.Currency = bill.Currency; |
|
|
|
|
billModel.Reason = bill.Reason; |
|
|
|
|
billModel.DateSent = bill.DateSent; |
|
|
|
|
billModel.Recipient = bill.Recipient; |
|
|
|
|
model.Transactions.Bills.Add(billModel); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<OneTime> oneTimes = _dbContext.Transactions.OfType<OneTime>().OrderByDescending(b => b.DateSent).ToList(); |
|
|
|
|
if (oneTimes != null) |
|
|
|
|
{ |
|
|
|
|
foreach (OneTime oneTime in oneTimes) |
|
|
|
|
{ |
|
|
|
|
OneTimeViewModel oneTimeModel = new OneTimeViewModel(); |
|
|
|
|
oneTimeModel.Amount = oneTime.Amount; |
|
|
|
|
oneTimeModel.Currency = oneTime.Currency; |
|
|
|
|
oneTimeModel.Reason = oneTime.Reason; |
|
|
|
|
oneTimeModel.DateSent = oneTime.DateSent; |
|
|
|
|
oneTimeModel.Recipient = oneTime.Recipient; |
|
|
|
|
model.Transactions.OneTimes.Add(oneTimeModel); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Donation> donations = _dbContext.Transactions.OfType<Donation>().OrderByDescending(b => b.DateSent).ToList(); |
|
|
|
|
if (donations != null) |
|
|
|
|
{ |
|
|
|
|
foreach (Donation donation in donations) |
|
|
|
|
{ |
|
|
|
|
DonationViewModel donationModel = new DonationViewModel(); |
|
|
|
|
donationModel.Amount = donation.Amount; |
|
|
|
|
donationModel.Currency = donation.Currency; |
|
|
|
|
donationModel.Reason = donation.Reason; |
|
|
|
|
donationModel.DateSent = donation.DateSent; |
|
|
|
|
donationModel.Sender = donation.Sender; |
|
|
|
|
model.Transactions.Donations.Add(donationModel); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// Takedown information
|
|
|
|
|
#region Takedowns
|
|
|
|
|
List<Takedown> takedowns = _dbContext.Takedowns.OrderByDescending(b => b.DateRequested).ToList(); |
|
|
|
|