From e8fd116eab89089d72743d45b81e74e3a646a738 Mon Sep 17 00:00:00 2001 From: Darkstack <1835601+darkstack@users.noreply.github.com> Date: Tue, 26 Feb 2019 01:26:03 +0100 Subject: [PATCH] Test WPF Desktop App with Caliburn And RestSharp --- LaDOSE.Src/ApiLaunch.bat | 0 .../LaDOSE.Api/Controllers/EventController.cs | 22 --- .../LaDOSE.Api/Controllers/UtilController.cs | 28 ++++ .../Controllers/WordPressController.cs | 30 ++++ LaDOSE.Src/LaDOSE.Api/Startup.cs | 1 + LaDOSE.Src/LaDOSE.DTO/ApplicationUser.cs | 15 ++ LaDOSE.Src/LaDOSE.DTO/Game.cs | 9 ++ LaDOSE.Src/LaDOSE.DTO/LaDOSE.DTO.csproj | 7 + LaDOSE.Src/LaDOSE.DTO/WPEvent.cs | 17 +++ LaDOSE.Src/LaDOSE.DesktopApp/App.config | 6 + LaDOSE.Src/LaDOSE.DesktopApp/App.xaml | 15 ++ LaDOSE.Src/LaDOSE.DesktopApp/App.xaml.cs | 17 +++ LaDOSE.Src/LaDOSE.DesktopApp/Bootstrapper.cs | 49 ++++++ .../LaDOSE.DesktopApp.csproj | 140 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 55 +++++++ .../Properties/Resources.Designer.cs | 71 +++++++++ .../Properties/Resources.resx | 117 +++++++++++++++ .../Properties/Settings.Designer.cs | 30 ++++ .../Properties/Settings.settings | 7 + .../LaDOSE.DesktopApp/Services/RestService.cs | 47 ++++++ .../ViewModels/GameViewModel.cs | 24 +++ .../ViewModels/ShellViewModel.cs | 18 +++ .../ViewModels/WordPressViewModel.cs | 24 +++ .../LaDOSE.DesktopApp/Views/GameView.xaml | 30 ++++ .../LaDOSE.DesktopApp/Views/GameView.xaml.cs | 28 ++++ .../LaDOSE.DesktopApp/Views/ShellView.xaml | 46 ++++++ .../LaDOSE.DesktopApp/Views/ShellView.xaml.cs | 29 ++++ .../LaDOSE.DesktopApp/Views/WpView.xaml | 30 ++++ .../LaDOSE.DesktopApp/Views/WpView.xaml.cs | 28 ++++ LaDOSE.Src/LaDOSE.DesktopApp/packages.config | 6 + LaDOSE.Src/LaDOSE.DiscordBot/Command/Todo.cs | 3 +- .../LaDOSE.DiscordBot/Service/TodoService.cs | 5 +- .../LaDOSE.Entity/Wordpress/WPBooking.cs | 1 + LaDOSE.Src/LaDOSE.Entity/Wordpress/WPEvent.cs | 2 +- .../Interface/IWordPressService.cs | 10 ++ .../LaDOSE.Service/Service/BaseService.cs | 11 +- .../Service/WordPressService.cs | 22 +++ LaDOSE.Src/LaDOSE.sln | 26 ++++ 38 files changed, 996 insertions(+), 30 deletions(-) create mode 100644 LaDOSE.Src/ApiLaunch.bat create mode 100644 LaDOSE.Src/LaDOSE.Api/Controllers/UtilController.cs create mode 100644 LaDOSE.Src/LaDOSE.Api/Controllers/WordPressController.cs create mode 100644 LaDOSE.Src/LaDOSE.DTO/ApplicationUser.cs create mode 100644 LaDOSE.Src/LaDOSE.DTO/Game.cs create mode 100644 LaDOSE.Src/LaDOSE.DTO/LaDOSE.DTO.csproj create mode 100644 LaDOSE.Src/LaDOSE.DTO/WPEvent.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/App.config create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/App.xaml create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/App.xaml.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Bootstrapper.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/LaDOSE.DesktopApp.csproj create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Properties/AssemblyInfo.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Properties/Resources.Designer.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Properties/Resources.resx create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Properties/Settings.Designer.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Properties/Settings.settings create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Services/RestService.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/GameViewModel.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/ShellViewModel.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/WordPressViewModel.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Views/GameView.xaml create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Views/GameView.xaml.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Views/WpView.xaml create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/Views/WpView.xaml.cs create mode 100644 LaDOSE.Src/LaDOSE.DesktopApp/packages.config create mode 100644 LaDOSE.Src/LaDOSE.Service/Interface/IWordPressService.cs create mode 100644 LaDOSE.Src/LaDOSE.Service/Service/WordPressService.cs diff --git a/LaDOSE.Src/ApiLaunch.bat b/LaDOSE.Src/ApiLaunch.bat new file mode 100644 index 0000000..e69de29 diff --git a/LaDOSE.Src/LaDOSE.Api/Controllers/EventController.cs b/LaDOSE.Src/LaDOSE.Api/Controllers/EventController.cs index f32a9fb..e801e22 100644 --- a/LaDOSE.Src/LaDOSE.Api/Controllers/EventController.cs +++ b/LaDOSE.Src/LaDOSE.Api/Controllers/EventController.cs @@ -38,26 +38,4 @@ namespace LaDOSE.Api.Controllers } } - - [Authorize] - [Produces("application/json")] - [Route("api/[controller]")] - public class UtilController : Controller - { - private IUtilService _service; - - public UtilController(IUtilService service) - { - _service = service; - } - - - - [HttpGet("UpdateBooking")] - public bool UpdateBooking() - { - return _service.UpdateBooking(); - - } - } } \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Api/Controllers/UtilController.cs b/LaDOSE.Src/LaDOSE.Api/Controllers/UtilController.cs new file mode 100644 index 0000000..d7764a0 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Api/Controllers/UtilController.cs @@ -0,0 +1,28 @@ +using LaDOSE.Business.Interface; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace LaDOSE.Api.Controllers +{ + [Authorize] + [Produces("application/json")] + [Route("api/[controller]")] + public class UtilController : Controller + { + private IUtilService _service; + + public UtilController(IUtilService service) + { + _service = service; + } + + + + [HttpGet("UpdateBooking")] + public bool UpdateBooking() + { + return _service.UpdateBooking(); + + } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Api/Controllers/WordPressController.cs b/LaDOSE.Src/LaDOSE.Api/Controllers/WordPressController.cs new file mode 100644 index 0000000..fea67c3 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Api/Controllers/WordPressController.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using LaDOSE.Business.Interface; +using LaDOSE.Entity.Wordpress; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace LaDOSE.Api.Controllers +{ + [Authorize] + [Produces("application/json")] + [Route("api/[controller]")] + public class WordPressController : Controller + { + // GET + + public WordPressController(IWordPressService service) + { + _service = service; + } + + private IWordPressService _service; + + [HttpGet("WPEvent")] + public List Event() + { + return _service.GetWpEvent(); + + } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Api/Startup.cs b/LaDOSE.Src/LaDOSE.Api/Startup.cs index 6758974..e838a4c 100644 --- a/LaDOSE.Src/LaDOSE.Api/Startup.cs +++ b/LaDOSE.Src/LaDOSE.Api/Startup.cs @@ -100,6 +100,7 @@ namespace LaDOSE.Api services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddTransient(p => new ChallongeProvider(this.Configuration["ApiKey:ChallongeApiKey"])); } diff --git a/LaDOSE.Src/LaDOSE.DTO/ApplicationUser.cs b/LaDOSE.Src/LaDOSE.DTO/ApplicationUser.cs new file mode 100644 index 0000000..077e440 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DTO/ApplicationUser.cs @@ -0,0 +1,15 @@ + +namespace LaDOSE.DTO +{ + public class ApplicationUser + { + public int Id { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public string Username { get; set; } + public string Password { get; set; } + + public string Token { get; set; } + } + +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DTO/Game.cs b/LaDOSE.Src/LaDOSE.DTO/Game.cs new file mode 100644 index 0000000..dab82f5 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DTO/Game.cs @@ -0,0 +1,9 @@ +namespace LaDOSE.DTO +{ + public class Game + { + public int Id { get; set; } + public string Name { get; set; } + public string ImgUrl { get; set; } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DTO/LaDOSE.DTO.csproj b/LaDOSE.Src/LaDOSE.DTO/LaDOSE.DTO.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DTO/LaDOSE.DTO.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/LaDOSE.Src/LaDOSE.DTO/WPEvent.cs b/LaDOSE.Src/LaDOSE.DTO/WPEvent.cs new file mode 100644 index 0000000..735f58c --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DTO/WPEvent.cs @@ -0,0 +1,17 @@ + +using System; +using System.Collections.Generic; + +namespace LaDOSE.DTO +{ + public class WPEvent + { + + // Id, Name, Slug, Date + public int Id { get; set; } + public string Name { get; set; } + public string Slug { get; set; } + public DateTime? Date { get; set; } + + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/App.config b/LaDOSE.Src/LaDOSE.DesktopApp/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/App.xaml b/LaDOSE.Src/LaDOSE.DesktopApp/App.xaml new file mode 100644 index 0000000..7af8590 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/App.xaml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/App.xaml.cs b/LaDOSE.Src/LaDOSE.DesktopApp/App.xaml.cs new file mode 100644 index 0000000..d6207db --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace LaDOSE.DesktopApp +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Bootstrapper.cs b/LaDOSE.Src/LaDOSE.DesktopApp/Bootstrapper.cs new file mode 100644 index 0000000..0e92fc0 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Bootstrapper.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Windows; +using Caliburn.Micro; +using LaDOSE.DesktopApp.Services; +using LaDOSE.DesktopApp.ViewModels; + +namespace LaDOSE.DesktopApp +{ + public class Bootstrapper : BootstrapperBase + { + private SimpleContainer container; + + public Bootstrapper() + { + Initialize(); + } + + protected override void Configure() + { + container = new SimpleContainer(); + + container.Singleton(); + + container.PerRequest(); + container.Singleton(); + } + + protected override void OnStartup(object sender, StartupEventArgs e) + { + DisplayRootViewFor(); + } + + protected override object GetInstance(Type service, string key) + { + return container.GetInstance(service, key); + } + + protected override IEnumerable GetAllInstances(Type service) + { + return container.GetAllInstances(service); + } + + protected override void BuildUp(object instance) + { + container.BuildUp(instance); + } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/LaDOSE.DesktopApp.csproj b/LaDOSE.Src/LaDOSE.DesktopApp/LaDOSE.DesktopApp.csproj new file mode 100644 index 0000000..f680129 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/LaDOSE.DesktopApp.csproj @@ -0,0 +1,140 @@ + + + + + Debug + AnyCPU + {A76AC851-4D43-4BF9-9034-F496888ADAFD} + WinExe + LaDOSE.DesktopApp + LaDOSE.DesktopApp + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Caliburn.Micro.Core.3.2.0\lib\net45\Caliburn.Micro.dll + + + ..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.dll + + + ..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll + + + ..\packages\RestSharp.106.6.5\lib\net452\RestSharp.dll + + + + + + ..\packages\Caliburn.Micro.3.2.0\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + + + + ShellView.xaml + + + GameView.xaml + + + WpView.xaml + + + App.xaml + Code + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + {61201da6-1bc9-4ba1-ac45-70104d391ecd} + LaDOSE.DTO + + + + + \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Properties/AssemblyInfo.cs b/LaDOSE.Src/LaDOSE.DesktopApp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d1ca200 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("LaDOSE.DesktopApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LaDOSE.DesktopApp")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Resources.Designer.cs b/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Resources.Designer.cs new file mode 100644 index 0000000..5e8e560 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LaDOSE.DesktopApp.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LaDOSE.DesktopApp.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Resources.resx b/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Settings.Designer.cs b/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Settings.Designer.cs new file mode 100644 index 0000000..ba88adf --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LaDOSE.DesktopApp.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Settings.settings b/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Services/RestService.cs b/LaDOSE.Src/LaDOSE.DesktopApp/Services/RestService.cs new file mode 100644 index 0000000..8f55da6 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Services/RestService.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Windows; +using LaDOSE.DTO; +using RestSharp; +using RestSharp.Authenticators; +using RestSharp.Serialization.Json; + +namespace LaDOSE.DesktopApp.Services +{ + public class RestService + { + public RestClient Client { get; set; } + + public RestService() + { + Client = new RestClient("http://localhost:5000/"); + var restRequest = new RestRequest("users/auth", Method.POST); + restRequest.AddJsonBody(new { username = "****", password = "*****" }); + var response = Client.Post(restRequest); + if (response.IsSuccessful) + { + JsonDeserializer d = new JsonDeserializer(); + var applicationUser = d.Deserialize(response); + Client.Authenticator = new JwtAuthenticator($"{applicationUser.Token}"); + } + else + { + throw new Exception("No Service Avaliable"); + } + } + + public List GetEvents() + { + var restRequest = new RestRequest("/api/wordpress/WPEvent", Method.GET); + var restResponse = Client.Get>(restRequest); + return restResponse.Data; + } + + public List GetGames() + { + var restRequest = new RestRequest("/api/Game", Method.GET); + var restResponse = Client.Get>(restRequest); + return restResponse.Data; + } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/GameViewModel.cs b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/GameViewModel.cs new file mode 100644 index 0000000..e41f4e6 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/GameViewModel.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Caliburn.Micro; +using LaDOSE.DesktopApp.Services; +using LaDOSE.DTO; + +namespace LaDOSE.DesktopApp.ViewModels +{ + public class GameViewModel : Screen + { + private RestService RestService { get; set; } + public GameViewModel(RestService restService) + { + this.RestService = restService; + } + + public void LoadGames() + { + this.Games = this.RestService.GetGames(); + NotifyOfPropertyChange("Games"); + } + + public List Games { get; set; } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/ShellViewModel.cs b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/ShellViewModel.cs new file mode 100644 index 0000000..515d1a8 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/ShellViewModel.cs @@ -0,0 +1,18 @@ +using Caliburn.Micro; +using LaDOSE.DesktopApp.Services; + +namespace LaDOSE.DesktopApp.ViewModels +{ + public class ShellViewModel : Conductor.Collection.OneActive + { + + public void LoadEvent() + { + ActivateItem(new WordPressViewModel(IoC.Get())); + } + public void LoadGames() + { + ActivateItem(new GameViewModel(IoC.Get())); + } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/WordPressViewModel.cs b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/WordPressViewModel.cs new file mode 100644 index 0000000..b17baf6 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/WordPressViewModel.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Caliburn.Micro; +using LaDOSE.DesktopApp.Services; +using LaDOSE.DTO; + +namespace LaDOSE.DesktopApp.ViewModels +{ + public class WordPressViewModel : Screen + { + private RestService RestService { get; set; } + public WordPressViewModel(RestService restService) + { + this.RestService = restService; + } + + public void LoadEvents() + { + this.Events = this.RestService.GetEvents(); + NotifyOfPropertyChange("Events"); + } + + public List Events { get; set; } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Views/GameView.xaml b/LaDOSE.Src/LaDOSE.DesktopApp/Views/GameView.xaml new file mode 100644 index 0000000..e84e698 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Views/GameView.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Views/GameView.xaml.cs b/LaDOSE.Src/LaDOSE.DesktopApp/Views/GameView.xaml.cs new file mode 100644 index 0000000..4a56060 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Views/GameView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace LaDOSE.DesktopApp.Views +{ + /// + /// Interaction logic for ShellView.xaml + /// + public partial class GameView : UserControl + { + public GameView() + { + InitializeComponent(); + } + } +} diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml b/LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml new file mode 100644 index 0000000..f4d9e52 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml.cs b/LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml.cs new file mode 100644 index 0000000..fb11036 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace LaDOSE.DesktopApp.Views +{ + /// + /// Interaction logic for ShellView.xaml + /// + public partial class ShellView : Window + { + public ShellView() + { + InitializeComponent(); + } + + } +} diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Views/WpView.xaml b/LaDOSE.Src/LaDOSE.DesktopApp/Views/WpView.xaml new file mode 100644 index 0000000..cc9e465 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Views/WpView.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Views/WpView.xaml.cs b/LaDOSE.Src/LaDOSE.DesktopApp/Views/WpView.xaml.cs new file mode 100644 index 0000000..8ceab74 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Views/WpView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace LaDOSE.DesktopApp.Views +{ + /// + /// Interaction logic for ShellView.xaml + /// + public partial class WordPressView : UserControl + { + public WordPressView() + { + InitializeComponent(); + } + } +} diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/packages.config b/LaDOSE.Src/LaDOSE.DesktopApp/packages.config new file mode 100644 index 0000000..5443c16 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.DesktopApp/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.DiscordBot/Command/Todo.cs b/LaDOSE.Src/LaDOSE.DiscordBot/Command/Todo.cs index 4c73f7d..2e0c720 100644 --- a/LaDOSE.Src/LaDOSE.DiscordBot/Command/Todo.cs +++ b/LaDOSE.Src/LaDOSE.DiscordBot/Command/Todo.cs @@ -14,7 +14,7 @@ namespace LaDOSE.DiscordBot.Command } [Command("todo")] - public async Task TwitchAsync(CommandContext ctx, string command,params string[] todo) + public async Task TodoAsync(CommandContext ctx, string command,params string[] todo) { await ctx.TriggerTypingAsync(); switch (command.ToUpperInvariant()) @@ -34,6 +34,7 @@ namespace LaDOSE.DiscordBot.Command }; await ctx.RespondAsync($"invalid id"); break; + } //await ctx.RespondAsync($"command : {command}, todo: {todo} "); } diff --git a/LaDOSE.Src/LaDOSE.DiscordBot/Service/TodoService.cs b/LaDOSE.Src/LaDOSE.DiscordBot/Service/TodoService.cs index dd0d37c..3299155 100644 --- a/LaDOSE.Src/LaDOSE.DiscordBot/Service/TodoService.cs +++ b/LaDOSE.Src/LaDOSE.DiscordBot/Service/TodoService.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; namespace LaDOSE.DiscordBot.Service { @@ -48,7 +49,7 @@ namespace LaDOSE.DiscordBot.Service string returnText = ""; var text = File.ReadAllText(db); var i = 0; - foreach (var line in text.Split('\n')) + foreach (var line in text.Split()) { if(!string.IsNullOrEmpty(line)) returnText += $"{++i}. {line}"; diff --git a/LaDOSE.Src/LaDOSE.Entity/Wordpress/WPBooking.cs b/LaDOSE.Src/LaDOSE.Entity/Wordpress/WPBooking.cs index b1c2647..b032296 100644 --- a/LaDOSE.Src/LaDOSE.Entity/Wordpress/WPBooking.cs +++ b/LaDOSE.Src/LaDOSE.Entity/Wordpress/WPBooking.cs @@ -10,6 +10,7 @@ public int WPUserId { get; set; } public WPUser WPUser { get; set; } public string Message { get; set; } + public string Meta { get; set; } } diff --git a/LaDOSE.Src/LaDOSE.Entity/Wordpress/WPEvent.cs b/LaDOSE.Src/LaDOSE.Entity/Wordpress/WPEvent.cs index 49aa138..2638989 100644 --- a/LaDOSE.Src/LaDOSE.Entity/Wordpress/WPEvent.cs +++ b/LaDOSE.Src/LaDOSE.Entity/Wordpress/WPEvent.cs @@ -11,7 +11,7 @@ namespace LaDOSE.Entity.Wordpress public int Id { get; set; } public string Name { get; set; } public string Slug { get; set; } - public DateTime Date { get; set; } + public DateTime? Date { get; set; } public virtual IEnumerable WPBookings { get; set; } } diff --git a/LaDOSE.Src/LaDOSE.Service/Interface/IWordPressService.cs b/LaDOSE.Src/LaDOSE.Service/Interface/IWordPressService.cs new file mode 100644 index 0000000..fc6ab75 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Service/Interface/IWordPressService.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using LaDOSE.Entity.Wordpress; + +namespace LaDOSE.Business.Interface +{ + public interface IWordPressService + { + List GetWpEvent(); + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/Service/BaseService.cs b/LaDOSE.Src/LaDOSE.Service/Service/BaseService.cs index df7fb4c..d5f6a71 100644 --- a/LaDOSE.Src/LaDOSE.Service/Service/BaseService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Service/BaseService.cs @@ -6,34 +6,37 @@ using Microsoft.EntityFrameworkCore; namespace LaDOSE.Business.Service { - - - public class BaseService : IBaseService where T : class + public class BaseService : IBaseService where T : class { protected LaDOSEDbContext _context; + public BaseService(LaDOSEDbContext context) { - this._context = context; + _context = context; } public virtual IEnumerable GetAll() { return _context.Set().ToList(); } + public virtual T GetById(int id) { return _context.Find(id); } + public virtual T Create(T entity) { var added = _context.Add(entity); return added.Entity; } + public virtual bool Update(T entity) { var entityEntry = _context.Update(entity); return _context.Entry(entityEntry).State == EntityState.Unchanged; } + public virtual bool Delete(int id) { var find = _context.Find(id); diff --git a/LaDOSE.Src/LaDOSE.Service/Service/WordPressService.cs b/LaDOSE.Src/LaDOSE.Service/Service/WordPressService.cs new file mode 100644 index 0000000..37b6c12 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Service/Service/WordPressService.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using System.Linq; +using LaDOSE.Business.Interface; +using LaDOSE.Entity.Context; +using LaDOSE.Entity.Wordpress; + +namespace LaDOSE.Business.Service +{ + public class WordPressService : IWordPressService + { + private LaDOSEDbContext _context; + public WordPressService(LaDOSEDbContext context) + { + this._context = context; + } + + public List GetWpEvent() + { + return _context.Set().ToList(); + } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.sln b/LaDOSE.Src/LaDOSE.sln index 3f54d7b..26176aa 100644 --- a/LaDOSE.Src/LaDOSE.sln +++ b/LaDOSE.Src/LaDOSE.sln @@ -11,6 +11,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.Entity", "LaDOSE.Ent EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.Business", "LaDOSE.Service\LaDOSE.Business.csproj", "{952DE665-70B5-492B-BE91-D0111E3BD907}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaDOSE.DesktopApp", "LaDOSE.DesktopApp\LaDOSE.DesktopApp.csproj", "{A76AC851-4D43-4BF9-9034-F496888ADAFD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.DTO", "LaDOSE.DTO\LaDOSE.DTO.csproj", "{61201DA6-1BC9-4BA1-AC45-70104D391ECD}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Api", "Api", "{6FC9438E-D93E-4E63-9342-F8A966EE2D06}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Desktop", "Desktop", "{DD52FE00-B822-4DE3-B369-2BFB5F808130}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bot", "Bot", "{8B9C38FB-2A83-482D-966C-06A5EA1749EB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,10 +43,26 @@ Global {952DE665-70B5-492B-BE91-D0111E3BD907}.Debug|Any CPU.Build.0 = Debug|Any CPU {952DE665-70B5-492B-BE91-D0111E3BD907}.Release|Any CPU.ActiveCfg = Release|Any CPU {952DE665-70B5-492B-BE91-D0111E3BD907}.Release|Any CPU.Build.0 = Release|Any CPU + {A76AC851-4D43-4BF9-9034-F496888ADAFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A76AC851-4D43-4BF9-9034-F496888ADAFD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A76AC851-4D43-4BF9-9034-F496888ADAFD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A76AC851-4D43-4BF9-9034-F496888ADAFD}.Release|Any CPU.Build.0 = Release|Any CPU + {61201DA6-1BC9-4BA1-AC45-70104D391ECD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61201DA6-1BC9-4BA1-AC45-70104D391ECD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61201DA6-1BC9-4BA1-AC45-70104D391ECD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61201DA6-1BC9-4BA1-AC45-70104D391ECD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {C1E8FAF6-3A75-44AC-938D-CA56A5322D1C} = {8B9C38FB-2A83-482D-966C-06A5EA1749EB} + {4D7ED4CC-F78F-4860-B8CE-DA01DCACCBB9} = {6FC9438E-D93E-4E63-9342-F8A966EE2D06} + {B32A4AD5-9A4B-4D12-AAD5-55541F170E2A} = {6FC9438E-D93E-4E63-9342-F8A966EE2D06} + {952DE665-70B5-492B-BE91-D0111E3BD907} = {6FC9438E-D93E-4E63-9342-F8A966EE2D06} + {A76AC851-4D43-4BF9-9034-F496888ADAFD} = {DD52FE00-B822-4DE3-B369-2BFB5F808130} + {61201DA6-1BC9-4BA1-AC45-70104D391ECD} = {6FC9438E-D93E-4E63-9342-F8A966EE2D06} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D47DEDD0-C906-439D-81E4-D86BBE723B8C} EndGlobalSection