Country and currency data

This commit is contained in:
CodeLiturgy 2022-08-13 03:59:37 +01:00
parent 245fdbc7f6
commit 6f60f74c90
9 changed files with 33 additions and 87 deletions

View File

@ -1 +0,0 @@


View File

@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\include\MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\include\Math-Expression-Evaluator\SimpleExpressionEvaluator\SimpleExpressionEvaluator.csproj" />
</ItemGroup>
<Import Project="..\include\MapTo\src\BlueWest.MapTo\MapTo.props" />
<ItemGroup>

View File

@ -1,25 +0,0 @@
using System;
using System.Security.Cryptography;
namespace BlueWest.Data
{
public class CodeGenerator
{
/*public string GetInviteCode(bool isBase64 = false)
{
var unix = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
var unixStr = unix.ToString("0000000000")[^6..];
byte[] bytes = RandomNumberGenerator.GetBytes(6);
var hexArray = Array.ConvertAll(bytes, x => x.ToString("X2"));
var hexStr = string.Concat(hexArray);
var resultCode = isBase64
? Convert.ToBase64String(Convert.FromHexString(unixStr + hexStr))
: unixStr + hexStr;
return resultCode;
}*/
}
}

View File

@ -0,0 +1,8 @@
namespace BlueWest.Data;
public class Country
{
public string StateName;
public int Code;
public string TLD;
}

View File

@ -0,0 +1,6 @@
namespace BlueWest.Data;
public class Currency
{
public Country Country { get; set; }
}

View File

@ -4,29 +4,17 @@ using MapTo;
namespace BlueWest.Data
{
public enum FinanceTransactionTypeEnum
{
ConsumerTypeBuy,
ConsumerTypeDonate,
BusinessIncomePayment,
BankTransferPayment
}
public class FinanceTransactionType
{
[Key] private FinanceTransactionTypeEnum Type;
private string FinanceTransactionTypeDescription;
}
[Key] public TimeSpan CreationDate { get; set; }
public enum MathOperationType
{
Add,
Sub,
Div,
Mul
public string Name;
private string Description;
}
[MapFrom(typeof(FinanceTransactionInsertDto))]
public partial class FinanceTransaction
{
@ -35,7 +23,7 @@ namespace BlueWest.Data
public TimeSpan UserId { get; set; }
public string Currency { get; }
public FinanceTransactionType FinanceTransactionType {get;}
public FinanceTransactionType Type {get;}
private string FinanceTransactionDescription;

View File

@ -1,22 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using SimpleExpressionEvaluator;
namespace BlueWest.Data;
public class MathOperation
{
[Key] public TimeSpan CreationDate { get; set; }
public MathOperationType MathOperationType { get; }
public double LeftAmount { get; }
public double RightAmount { get; }
public string MathOperationDescription { get; }
private bool _isCalculated = false;
private double _resultingAmount;
private string _expression;
public double ResultingAmount
private decimal _resultingAmount;
private ExpressionEvaluator _expressionEvaluator = new ExpressionEvaluator();
public decimal ResultingAmount
{
get
{
@ -26,32 +27,12 @@ public class MathOperation
}
public MathOperation() { }
public MathOperation(MathOperationType mathOperationType, double leftAmount, double rightAmount, string mathOperationDescription)
{
MathOperationType = mathOperationType;
LeftAmount = leftAmount;
RightAmount = rightAmount;
MathOperationDescription = mathOperationDescription;
}
public void Calculate()
public MathOperation(string expression, Dictionary<string, decimal> letters)
{
_resultingAmount = _expressionEvaluator.Evaluate(expression, letters);
_isCalculated = true;
switch (MathOperationType)
{
case MathOperationType.Add:
_resultingAmount = LeftAmount + RightAmount;
return;
case MathOperationType.Div:
_resultingAmount = LeftAmount / RightAmount;
return;
case MathOperationType.Mul:
_resultingAmount = LeftAmount * RightAmount;
return;
case MathOperationType.Sub:
_resultingAmount = LeftAmount - RightAmount;
return;
}
}
}

View File

@ -1,11 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BlueWest.Data
{
public static class UserExtensions
{
}
}

View File

@ -1 +0,0 @@