Benjamin Arhen
2 years ago
16 changed files with 277 additions and 68 deletions
@ -0,0 +1,4 @@ |
|||||
|
[*.cs] |
||||
|
|
||||
|
# IDE0021: Use block body for constructor |
||||
|
csharp_style_expression_bodied_constructors = when_on_single_line |
@ -0,0 +1,25 @@ |
|||||
|
namespace Biskilog_Accounting.Client.Elements |
||||
|
{ |
||||
|
public partial class Sidebar |
||||
|
{ |
||||
|
private double m_activeId = 1; |
||||
|
private string m_class { get; set; } = "layout-menu"; |
||||
|
|
||||
|
private void HandleMenuClick(double a_selectedId) |
||||
|
{ |
||||
|
m_activeId = a_selectedId; |
||||
|
StateHasChanged(); |
||||
|
} |
||||
|
private void Collapse() |
||||
|
{ |
||||
|
if (m_class == "layout-menu") |
||||
|
{ |
||||
|
m_class = "layout-menu-collapsed"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
m_class = "layout-menu"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
using Biskilog_Accounting.Shared.Interfaces; |
||||
|
|
||||
|
namespace Biskilog_Accounting.Client.Pages.Dashboard |
||||
|
{ |
||||
|
public partial class Dashboard |
||||
|
{ |
||||
|
private readonly ITokenService m_tokenService; |
||||
|
private double CurrentTradeSale = 7000; |
||||
|
private double PreviousTradeSale = 2000.80; |
||||
|
private string username { get; set; } |
||||
|
public Dashboard() { } |
||||
|
public Dashboard(ITokenService a_tokenService) => m_tokenService = a_tokenService; |
||||
|
protected override void OnInitialized() |
||||
|
{ |
||||
|
username = "username"; |
||||
|
base.OnInitialized(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
@using Biskilog_Accounting.Shared.Interfaces; |
||||
|
@inject ICalculator m_calculator; |
||||
|
|
||||
|
<div class="card"> |
||||
|
<div class="d-flex align-items-end row"> |
||||
|
<div class="col-sm-7"> |
||||
|
<div class="card-body"> |
||||
|
<h5 class="card-title text-primary">@(CurrentTradeSales > PreviousTradeSales ? "Congratulations 🎉" : "Tough shift there") @Username!</h5> |
||||
|
<p class="mb-4"> |
||||
|
@m_remarks |
||||
|
</p> |
||||
|
<a href="javascript:;" class="btn btn-sm btn-outline-primary">View Trade Summary</a> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-sm-5 text-center text-sm-left"> |
||||
|
<div class="card-body pb-0 px-0 px-md-4"> |
||||
|
<img src="../assets/img/illustrations/man-with-laptop-light.png" |
||||
|
height="140" |
||||
|
alt="View Badge User" |
||||
|
data-app-dark-img="illustrations/man-with-laptop-dark.png" |
||||
|
data-app-light-img="illustrations/man-with-laptop-light.png" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
@ -0,0 +1,40 @@ |
|||||
|
using Microsoft.AspNetCore.Components; |
||||
|
|
||||
|
namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements |
||||
|
{ |
||||
|
public partial class WelcomeCard |
||||
|
{ |
||||
|
[Parameter] |
||||
|
public string Username { get; set; } = string.Empty; |
||||
|
|
||||
|
[Parameter] |
||||
|
public double CurrentTradeSales { get; set; } = 0; |
||||
|
[Parameter] |
||||
|
public double PreviousTradeSales { get; set; } = 0; |
||||
|
|
||||
|
private string m_remarks { get; set; } = ""; |
||||
|
|
||||
|
protected override void OnInitialized() |
||||
|
{ |
||||
|
CalculateStatistic(); |
||||
|
|
||||
|
base.OnInitialized(); |
||||
|
} |
||||
|
private void CalculateStatistic() |
||||
|
{ |
||||
|
if (CurrentTradeSales > PreviousTradeSales) |
||||
|
{ |
||||
|
double change = (CurrentTradeSales / (CurrentTradeSales + PreviousTradeSales)) * 100; |
||||
|
string changePercent = change.ToString("0.00") + "%"; |
||||
|
m_remarks = $"You made a total of {m_calculator.FormatMoneyWithCurrency(CurrentTradeSales)} in the current trade, {changePercent} more than the previous trade sales"; |
||||
|
} |
||||
|
else if (PreviousTradeSales > CurrentTradeSales) { |
||||
|
double change = (CurrentTradeSales / (CurrentTradeSales + PreviousTradeSales)) * -100; |
||||
|
string changePercent = change.ToString("0.00") + "%"; |
||||
|
m_remarks = $"You made a total of {m_calculator.FormatMoneyWithCurrency(CurrentTradeSales)} in the current trade, {changePercent} less than the previous trade sales"; |
||||
|
} else { |
||||
|
m_remarks = $"You made a total of {m_calculator.FormatMoneyWithCurrency(CurrentTradeSales)} in the current trade, same as the previous trade sales"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Globalization; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Biskilog_Accounting.Shared.Interfaces |
||||
|
{ |
||||
|
public interface ICalculator |
||||
|
{ |
||||
|
double CalculatePercentage(); |
||||
|
string FormatMoneyWithCurrency(double a_amount); |
||||
|
NumberFormatInfo GetCurrencyCode(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
using Biskilog_Accounting.Shared.Interfaces; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Globalization; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Biskilog_Accounting.Shared.ServiceRepo |
||||
|
{ |
||||
|
public class CalculatorService : ICalculator |
||||
|
{ |
||||
|
public double CalculatePercentage() |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
public string FormatMoneyWithCurrency(double a_amount) |
||||
|
{ |
||||
|
return string.Format(GetCurrencyCode(), "{0:C2}", a_amount); |
||||
|
} |
||||
|
|
||||
|
public NumberFormatInfo GetCurrencyCode() |
||||
|
{ |
||||
|
//TODO have a better implementation
|
||||
|
|
||||
|
// Specify the locale for Ghana
|
||||
|
string locale = "en-GH"; |
||||
|
|
||||
|
// Get the NumberFormatInfo for the specified locale
|
||||
|
NumberFormatInfo numberFormatInfo = new CultureInfo(locale).NumberFormat; |
||||
|
|
||||
|
// Set the currency symbol to Ghanaian cedi
|
||||
|
numberFormatInfo.CurrencySymbol = "GH₵"; |
||||
|
|
||||
|
return numberFormatInfo; |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue