From b4037f2c33dc44ab7e7b8107dc817a76a6192612 Mon Sep 17 00:00:00 2001 From: appelemac Date: Sun, 4 Sep 2016 16:57:02 +0200 Subject: [PATCH] seperated models, added alias attribute --- .../Commands/Models/MeasurementUnit.cs | 11 ++++++++ .../Modules/Searches/Commands/Models/Rates.cs | 14 +++++++++++ .../Searches/Commands/UnitConversion.cs | 25 +++---------------- 3 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 src/NadekoBot/Modules/Searches/Commands/Models/MeasurementUnit.cs create mode 100644 src/NadekoBot/Modules/Searches/Commands/Models/Rates.cs diff --git a/src/NadekoBot/Modules/Searches/Commands/Models/MeasurementUnit.cs b/src/NadekoBot/Modules/Searches/Commands/Models/MeasurementUnit.cs new file mode 100644 index 00000000..ba4d1bb7 --- /dev/null +++ b/src/NadekoBot/Modules/Searches/Commands/Models/MeasurementUnit.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace NadekoBot.Modules.Searches.Commands.Models +{ + public class MeasurementUnit + { + public List Triggers { get; set; } + public string UnitType { get; set; } + public decimal Modifier { get; set; } + } +} diff --git a/src/NadekoBot/Modules/Searches/Commands/Models/Rates.cs b/src/NadekoBot/Modules/Searches/Commands/Models/Rates.cs new file mode 100644 index 00000000..5aed22fa --- /dev/null +++ b/src/NadekoBot/Modules/Searches/Commands/Models/Rates.cs @@ -0,0 +1,14 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; + +namespace NadekoBot.Modules.Searches.Commands.Models +{ + public class Rates + { + public string Base { get; set; } + public DateTime Date { get; set; } + [JsonProperty("rates")] + public Dictionary ConversionRates { get; set; } + } +} diff --git a/src/NadekoBot/Modules/Searches/Commands/UnitConversion.cs b/src/NadekoBot/Modules/Searches/Commands/UnitConversion.cs index 94fe0c77..856f541e 100644 --- a/src/NadekoBot/Modules/Searches/Commands/UnitConversion.cs +++ b/src/NadekoBot/Modules/Searches/Commands/UnitConversion.cs @@ -2,6 +2,7 @@ using Discord.Commands; using NadekoBot.Attributes; using NadekoBot.Extensions; +using NadekoBot.Modules.Searches.Commands.Models; using NadekoBot.Services; using NadekoBot.Services.Database.Models; using Newtonsoft.Json; @@ -91,7 +92,7 @@ namespace NadekoBot.Modules.Searches public List Units { get; set; } - [LocalizedCommand, LocalizedDescription, LocalizedSummary] + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] [RequireContext(ContextType.Guild)] public async Task ConvertListE(IUserMessage msg) //extended and bugged list { @@ -110,7 +111,7 @@ namespace NadekoBot.Modules.Searches } await msg.ReplyLong(sb.ToString(), "```xl", "```", "```xl"); } - [LocalizedCommand, LocalizedDescription, LocalizedSummary] + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] [RequireContext(ContextType.Guild)] public async Task ConvertList(IUserMessage msg) { @@ -124,7 +125,7 @@ namespace NadekoBot.Modules.Searches } await msg.ReplyLong(sb.ToString(), "```xl", "```", "```xl"); } - [LocalizedCommand, LocalizedDescription, LocalizedSummary] + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] public async Task Convert(IUserMessage msg, string origin, string target, decimal value) { var originUnit = Units.Find(x => x.Triggers.Select(y => y.ToLowerInvariant()).Contains(origin.ToLowerInvariant())); @@ -184,7 +185,6 @@ namespace NadekoBot.Modules.Searches } } - public static async Task UpdateCurrencyRates() { using (var http = new HttpClient()) @@ -193,22 +193,5 @@ namespace NadekoBot.Modules.Searches return JsonConvert.DeserializeObject(res); } } - - public class Rates - { - [JsonProperty("base")] - public string Base { get; set; } - [JsonProperty("date")] - public DateTime Date { get; set; } - [JsonProperty("rates")] - public Dictionary ConversionRates { get; set; } - } - - public class MeasurementUnit - { - public List Triggers { get; set; } - public string UnitType { get; set; } - public decimal Modifier { get; set; } - } } } \ No newline at end of file