Browse Source

Tweaked LicenseUtils

frogsoftware 1 year ago
parent
commit
2129bf7aa1
1 changed files with 12 additions and 7 deletions
  1. 12 7
      InABox.Core/Licensing/LicenseUtils.cs

+ 12 - 7
InABox.Core/Licensing/LicenseUtils.cs

@@ -96,23 +96,23 @@ namespace InABox.Core
 
 
         #region Fees & Discounts
         #region Fees & Discounts
 
 
-        private static readonly Dictionary<Type, double> _licensefees = new Dictionary<Type, double>();
+        private static readonly Dictionary<String, double> _licensefees = new Dictionary<String, double>();
 
 
         private static readonly Dictionary<int, double> _periods = new Dictionary<int, double>();
         private static readonly Dictionary<int, double> _periods = new Dictionary<int, double>();
 
 
         private static readonly Dictionary<int, double> _userDiscounts = new Dictionary<int, double>();
         private static readonly Dictionary<int, double> _userDiscounts = new Dictionary<int, double>();
 
 
-        public static double GetLicenseFee(Type type)
+        public static double GetLicenseFee(String type)
         {
         {
             return _licensefees.GetValueOrDefault(type, 0);
             return _licensefees.GetValueOrDefault(type, 0);
         }
         }
 
 
         public static double GetLicenseFee<T>() where T : LicenseToken
         public static double GetLicenseFee<T>() where T : LicenseToken
         {
         {
-            return GetLicenseFee(typeof(T));
+            return GetLicenseFee(typeof(T).EntityName());
         }
         }
 
 
-        public static IEnumerable<Type> LicenseTypes()
+        public static IEnumerable<String> LicenseTypes()
         {
         {
             return _licensefees.Keys;
             return _licensefees.Keys;
         }
         }
@@ -144,7 +144,7 @@ namespace InABox.Core
             return _periods.Keys;
             return _periods.Keys;
         }
         }
 
 
-        public static double CalculateLicenseFee(Dictionary<Type, int> licenses, int time)
+        public static double CalculateLicenseFee(Dictionary<String, int> licenses, int time)
         {
         {
             double licensefee = 0.00F;
             double licensefee = 0.00F;
             foreach (var license in licenses.Keys)
             foreach (var license in licenses.Keys)
@@ -168,7 +168,7 @@ namespace InABox.Core
             _userDiscounts.Clear();
             _userDiscounts.Clear();
 
 
             foreach (var license in summary.LicenseFees)
             foreach (var license in summary.LicenseFees)
-                _licensefees[CoreUtils.GetEntity(license.Key)] = license.Value;
+                _licensefees[license.Key] = license.Value;
             foreach (var (months, period) in summary.TimeDiscounts)
             foreach (var (months, period) in summary.TimeDiscounts)
                 _periods[months] = period;
                 _periods[months] = period;
             foreach (var (users, discount) in summary.UserDiscounts)
             foreach (var (users, discount) in summary.UserDiscounts)
@@ -230,6 +230,11 @@ namespace InABox.Core
         #endregion
         #endregion
     }
     }
 
 
+    public class LicenseSummaryRequest
+    {
+        public Guid RegistrationID { get; set; }
+    }
+    
     public class LicenseSummary
     public class LicenseSummary
     {
     {
         public LicenseSummary()
         public LicenseSummary()
@@ -238,7 +243,7 @@ namespace InABox.Core
             TimeDiscounts = new Dictionary<int, double>();
             TimeDiscounts = new Dictionary<int, double>();
             UserDiscounts = new Dictionary<int, double>();
             UserDiscounts = new Dictionary<int, double>();
         }
         }
-
+        
         public Dictionary<string, double> LicenseFees { get; set; }
         public Dictionary<string, double> LicenseFees { get; set; }
         public Dictionary<int, double> TimeDiscounts { get; set; }
         public Dictionary<int, double> TimeDiscounts { get; set; }
         public Dictionary<int, double> UserDiscounts { get; set; }
         public Dictionary<int, double> UserDiscounts { get; set; }