From 10b4edfd8a37866f55967fc8132a934556481b42 Mon Sep 17 00:00:00 2001 From: CWX Date: Sun, 19 Jan 2025 22:50:50 +0000 Subject: [PATCH] finish off handbook helper --- Libraries/Core/Helpers/HandbookHelper.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Libraries/Core/Helpers/HandbookHelper.cs b/Libraries/Core/Helpers/HandbookHelper.cs index 8270305e..5ba7e9e9 100644 --- a/Libraries/Core/Helpers/HandbookHelper.cs +++ b/Libraries/Core/Helpers/HandbookHelper.cs @@ -169,12 +169,18 @@ public class HandbookHelper( /// currency count in desired type public double FromRUB(double roubleCurrencyCount, string currencyTypeTo) { - throw new NotImplementedException(); + if (currencyTypeTo == Money.ROUBLES) { + return roubleCurrencyCount; + } + + // Get price of currency from handbook + var price = GetTemplatePrice(currencyTypeTo); + return price is not null ? Math.Max(1, Math.Round((double)(roubleCurrencyCount / price))) : 0; } public HandbookCategory GetCategoryById(string handbookId) { - throw new NotImplementedException(); + return _databaseService.GetHandbook().Categories.FirstOrDefault(category => category.Id == handbookId); } }