REST to a .Net Standard Library
Test REST in discord bot and WPF Small improvements
This commit is contained in:
@@ -14,47 +14,61 @@ namespace LaDOSE.Api.Controllers
|
|||||||
public class WordPressController : Controller
|
public class WordPressController : Controller
|
||||||
{
|
{
|
||||||
public IGameService GameService { get; }
|
public IGameService GameService { get; }
|
||||||
|
|
||||||
private IWordPressService _service;
|
private IWordPressService _service;
|
||||||
// GET
|
// GET
|
||||||
|
|
||||||
public WordPressController(IWordPressService service, IGameService gameService )
|
public WordPressController(IWordPressService service, IGameService gameService)
|
||||||
{
|
{
|
||||||
GameService = gameService;
|
GameService = gameService;
|
||||||
_service = service;
|
_service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("WPEvent")]
|
[HttpGet("WPEvent")]
|
||||||
public List<WPEventDTO> Event()
|
public List<WPEventDTO> Event()
|
||||||
{
|
{
|
||||||
var wpEvents = _service.GetWpEvent();
|
var wpEvents = _service.GetWpEvent();
|
||||||
foreach (var wpEvent in wpEvents)
|
foreach (var wpEvent in wpEvents)
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (var wpEventWpBooking in wpEvent.WPBookings)
|
foreach (var wpEventWpBooking in wpEvent.WPBookings)
|
||||||
{
|
{
|
||||||
wpEventWpBooking.WPEvent = null;
|
wpEventWpBooking.WPEvent = null;
|
||||||
wpEventWpBooking.WPUser.WPBookings = null;
|
wpEventWpBooking.WPUser.WPBookings = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Mapper.Map<List<WPEventDTO>>(wpEvents);
|
return Mapper.Map<List<WPEventDTO>>(wpEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("NextEvent")]
|
||||||
|
public WPEventDTO NextEvent()
|
||||||
|
{
|
||||||
|
var wpEvents = _service.GetNextWpEvent();
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var wpEventWpBooking in wpEvents.WPBookings)
|
||||||
|
{
|
||||||
|
wpEventWpBooking.WPEvent = null;
|
||||||
|
wpEventWpBooking.WPUser.WPBookings = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Mapper.Map<WPEventDTO>(wpEvents);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("GetUsers/{wpEventId}/{gameId}")]
|
[HttpGet("GetUsers/{wpEventId}/{gameId}")]
|
||||||
public List<WPUserDTO> GetUsers(int wpEventId, int gameId)
|
public List<WPUserDTO> GetUsers(int wpEventId, int gameId)
|
||||||
{
|
{
|
||||||
var game = GameService.GetById(gameId);
|
var game = GameService.GetById(gameId);
|
||||||
return Mapper.Map<List<WPUserDTO>>(_service.GetBooking(wpEventId, game));
|
return Mapper.Map<List<WPUserDTO>>(_service.GetBooking(wpEventId, game));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("GetUsersOptions/{wpEventId}/{gameId}")]
|
[HttpGet("GetUsersOptions/{wpEventId}/{gameId}")]
|
||||||
public List<WPUserDTO> GetUsersOptions(int wpEventId, int gameId)
|
public List<WPUserDTO> GetUsersOptions(int wpEventId, int gameId)
|
||||||
{
|
{
|
||||||
var game = GameService.GetById(gameId);
|
var game = GameService.GetById(gameId);
|
||||||
return Mapper.Map<List<WPUserDTO>>(_service.GetBookingOptions(wpEventId, game));
|
return Mapper.Map<List<WPUserDTO>>(_service.GetBookingOptions(wpEventId, game));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -62,17 +76,16 @@ namespace LaDOSE.Api.Controllers
|
|||||||
public bool UpdateDb()
|
public bool UpdateDb()
|
||||||
{
|
{
|
||||||
return _service.UpdateBooking();
|
return _service.UpdateBooking();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("CreateChallonge/{gameId:int}/{wpEventId:int}")]
|
[HttpGet("CreateChallonge/{gameId:int}/{wpEventId:int}")]
|
||||||
public string CreateChallonge(int gameId, int wpEventId)
|
public string CreateChallonge(int gameId, int wpEventId)
|
||||||
{
|
{
|
||||||
return _service.CreateChallonge(gameId, wpEventId,null);
|
return _service.CreateChallonge(gameId, wpEventId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("CreateChallonge/{gameId:int}/{wpEventId:int}")]
|
[HttpPost("CreateChallonge/{gameId:int}/{wpEventId:int}")]
|
||||||
public string CreateChallonge(int gameId, int wpEventId, [FromBody]List<WPUser> additionalPlayer)
|
public string CreateChallonge(int gameId, int wpEventId, [FromBody] List<WPUser> additionalPlayer)
|
||||||
{
|
{
|
||||||
return _service.CreateChallonge(gameId, wpEventId, additionalPlayer);
|
return _service.CreateChallonge(gameId, wpEventId, additionalPlayer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public int Order { get; set; }
|
||||||
public string ImgUrl { get; set; }
|
public string ImgUrl { get; set; }
|
||||||
public string WordPressTag { get; set; }
|
public string WordPressTag { get; set; }
|
||||||
public string WordPressTagOs { get; set; }
|
public string WordPressTagOs { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
using System;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Interactivity;
|
||||||
|
|
||||||
|
namespace LaDOSE.DesktopApp.Behaviors
|
||||||
|
{
|
||||||
|
public class TextBoxInputRegExBehaviour : Behavior<TextBox>
|
||||||
|
{
|
||||||
|
#region DependencyProperties
|
||||||
|
public static readonly DependencyProperty RegularExpressionProperty =
|
||||||
|
DependencyProperty.Register("RegularExpression", typeof(string), typeof(TextBoxInputRegExBehaviour), new FrameworkPropertyMetadata(".*"));
|
||||||
|
|
||||||
|
public string RegularExpression
|
||||||
|
{
|
||||||
|
get { return (string)GetValue(RegularExpressionProperty); }
|
||||||
|
set { SetValue(RegularExpressionProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty MaxLengthProperty =
|
||||||
|
DependencyProperty.Register("MaxLength", typeof(int), typeof(TextBoxInputRegExBehaviour),
|
||||||
|
new FrameworkPropertyMetadata(int.MinValue));
|
||||||
|
|
||||||
|
public int MaxLength
|
||||||
|
{
|
||||||
|
get { return (int)GetValue(MaxLengthProperty); }
|
||||||
|
set { SetValue(MaxLengthProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty EmptyValueProperty =
|
||||||
|
DependencyProperty.Register("EmptyValue", typeof(string), typeof(TextBoxInputRegExBehaviour), null);
|
||||||
|
|
||||||
|
public string EmptyValue
|
||||||
|
{
|
||||||
|
get { return (string)GetValue(EmptyValueProperty); }
|
||||||
|
set { SetValue(EmptyValueProperty, value); }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attach our behaviour. Add event handlers
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnAttached()
|
||||||
|
{
|
||||||
|
base.OnAttached();
|
||||||
|
|
||||||
|
AssociatedObject.PreviewTextInput += PreviewTextInputHandler;
|
||||||
|
AssociatedObject.PreviewKeyDown += PreviewKeyDownHandler;
|
||||||
|
DataObject.AddPastingHandler(AssociatedObject, PastingHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deattach our behaviour. remove event handlers
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnDetaching()
|
||||||
|
{
|
||||||
|
base.OnDetaching();
|
||||||
|
|
||||||
|
AssociatedObject.PreviewTextInput -= PreviewTextInputHandler;
|
||||||
|
AssociatedObject.PreviewKeyDown -= PreviewKeyDownHandler;
|
||||||
|
DataObject.RemovePastingHandler(AssociatedObject, PastingHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Event handlers [PRIVATE] --------------------------------------
|
||||||
|
|
||||||
|
void PreviewTextInputHandler(object sender, TextCompositionEventArgs e)
|
||||||
|
{
|
||||||
|
string text;
|
||||||
|
if (this.AssociatedObject.Text.Length < this.AssociatedObject.CaretIndex)
|
||||||
|
text = this.AssociatedObject.Text;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Remaining text after removing selected text.
|
||||||
|
string remainingTextAfterRemoveSelection;
|
||||||
|
|
||||||
|
text = TreatSelectedText(out remainingTextAfterRemoveSelection)
|
||||||
|
? remainingTextAfterRemoveSelection.Insert(AssociatedObject.SelectionStart, e.Text)
|
||||||
|
: AssociatedObject.Text.Insert(this.AssociatedObject.CaretIndex, e.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Handled = !ValidateText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PreviewKeyDown event handler
|
||||||
|
/// </summary>
|
||||||
|
void PreviewKeyDownHandler(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(this.EmptyValue))
|
||||||
|
return;
|
||||||
|
|
||||||
|
string text = null;
|
||||||
|
|
||||||
|
// Handle the Backspace key
|
||||||
|
if (e.Key == Key.Back)
|
||||||
|
{
|
||||||
|
if (!this.TreatSelectedText(out text))
|
||||||
|
{
|
||||||
|
if (AssociatedObject.SelectionStart > 0)
|
||||||
|
text = this.AssociatedObject.Text.Remove(AssociatedObject.SelectionStart - 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Handle the Delete key
|
||||||
|
else if (e.Key == Key.Delete)
|
||||||
|
{
|
||||||
|
// If text was selected, delete it
|
||||||
|
if (!this.TreatSelectedText(out text) && this.AssociatedObject.Text.Length > AssociatedObject.SelectionStart)
|
||||||
|
{
|
||||||
|
// Otherwise delete next symbol
|
||||||
|
text = this.AssociatedObject.Text.Remove(AssociatedObject.SelectionStart, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text == string.Empty)
|
||||||
|
{
|
||||||
|
this.AssociatedObject.Text = this.EmptyValue;
|
||||||
|
if (e.Key == Key.Back)
|
||||||
|
AssociatedObject.SelectionStart++;
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PastingHandler(object sender, DataObjectPastingEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.DataObject.GetDataPresent(DataFormats.Text))
|
||||||
|
{
|
||||||
|
string text = Convert.ToString(e.DataObject.GetData(DataFormats.Text));
|
||||||
|
|
||||||
|
if (!ValidateText(text))
|
||||||
|
e.CancelCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
e.CancelCommand();
|
||||||
|
}
|
||||||
|
#endregion Event handlers [PRIVATE] -----------------------------------
|
||||||
|
|
||||||
|
#region Auxiliary methods [PRIVATE] -----------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validate certain text by our regular expression and text length conditions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"> Text for validation </param>
|
||||||
|
/// <returns> True - valid, False - invalid </returns>
|
||||||
|
private bool ValidateText(string text)
|
||||||
|
{
|
||||||
|
return (new Regex(this.RegularExpression, RegexOptions.IgnoreCase)).IsMatch(text) && (MaxLength == int.MinValue || text.Length <= MaxLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle text selection
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>true if the character was successfully removed; otherwise, false. </returns>
|
||||||
|
private bool TreatSelectedText(out string text)
|
||||||
|
{
|
||||||
|
text = null;
|
||||||
|
if (AssociatedObject.SelectionLength <= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var length = this.AssociatedObject.Text.Length;
|
||||||
|
if (AssociatedObject.SelectionStart >= length)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (AssociatedObject.SelectionStart + AssociatedObject.SelectionLength >= length)
|
||||||
|
AssociatedObject.SelectionLength = length - AssociatedObject.SelectionStart;
|
||||||
|
|
||||||
|
text = this.AssociatedObject.Text.Remove(AssociatedObject.SelectionStart, AssociatedObject.SelectionLength);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endregion Auxiliary methods [PRIVATE] --------------------------------
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using LaDOSE.DesktopApp.Services;
|
|
||||||
using LaDOSE.DesktopApp.ViewModels;
|
using LaDOSE.DesktopApp.ViewModels;
|
||||||
|
using LaDOSE.REST;
|
||||||
|
|
||||||
namespace LaDOSE.DesktopApp
|
namespace LaDOSE.DesktopApp
|
||||||
{
|
{
|
||||||
@@ -18,14 +20,19 @@ namespace LaDOSE.DesktopApp
|
|||||||
|
|
||||||
protected override void Configure()
|
protected override void Configure()
|
||||||
{
|
{
|
||||||
|
|
||||||
container = new SimpleContainer();
|
container = new SimpleContainer();
|
||||||
|
|
||||||
container.Singleton<IWindowManager, WindowManager>();
|
container.Singleton<IWindowManager, WindowManager>();
|
||||||
|
container.Singleton<RestService>();
|
||||||
|
|
||||||
container.PerRequest<ShellViewModel>();
|
container.PerRequest<ShellViewModel>();
|
||||||
container.Singleton<RestService>();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void OnStartup(object sender, StartupEventArgs e)
|
protected override void OnStartup(object sender, StartupEventArgs e)
|
||||||
{
|
{
|
||||||
DisplayRootViewFor<ShellViewModel>();
|
DisplayRootViewFor<ShellViewModel>();
|
||||||
@@ -44,6 +51,7 @@ namespace LaDOSE.DesktopApp
|
|||||||
protected override void BuildUp(object instance)
|
protected override void BuildUp(object instance)
|
||||||
{
|
{
|
||||||
container.BuildUp(instance);
|
container.BuildUp(instance);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,8 +66,8 @@
|
|||||||
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
|
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
|
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="RestSharp, Version=106.6.5.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
<Reference Include="RestSharp, Version=106.6.9.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\RestSharp.106.6.5\lib\net452\RestSharp.dll</HintPath>
|
<HintPath>..\packages\RestSharp.106.6.9\lib\net452\RestSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
@@ -99,12 +99,12 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="Behaviors\TextBoxInputRegExBehaviour.cs" />
|
||||||
<Compile Include="Behaviors\MultiSelectorBehaviours.cs" />
|
<Compile Include="Behaviors\MultiSelectorBehaviours.cs" />
|
||||||
<Compile Include="Bootstrapper.cs" />
|
<Compile Include="Bootstrapper.cs" />
|
||||||
<Compile Include="Themes\LeftMarginMultiplierConverter.cs" />
|
<Compile Include="Themes\LeftMarginMultiplierConverter.cs" />
|
||||||
<Compile Include="Themes\TreeViewItemExtensions.cs" />
|
<Compile Include="Themes\TreeViewItemExtensions.cs" />
|
||||||
<Compile Include="Utils\PhpSerialize.cs" />
|
<Compile Include="Utils\PhpSerialize.cs" />
|
||||||
<Compile Include="Services\RestService.cs" />
|
|
||||||
<Compile Include="UserControls\BookingUserControl.xaml.cs">
|
<Compile Include="UserControls\BookingUserControl.xaml.cs">
|
||||||
<DependentUpon>BookingUserControl.xaml</DependentUpon>
|
<DependentUpon>BookingUserControl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -189,6 +189,10 @@
|
|||||||
<Project>{61201da6-1bc9-4ba1-ac45-70104d391ecd}</Project>
|
<Project>{61201da6-1bc9-4ba1-ac45-70104d391ecd}</Project>
|
||||||
<Name>LaDOSE.DTO</Name>
|
<Name>LaDOSE.DTO</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\LaDOSE.REST\LaDOSE.REST.csproj">
|
||||||
|
<Project>{692c2a72-ab7e-4502-bed8-aa2afa1761cb}</Project>
|
||||||
|
<Name>LaDOSE.REST</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="64x64.ico" />
|
<Resource Include="64x64.ico" />
|
||||||
@@ -208,5 +212,8 @@
|
|||||||
<Install>false</Install>
|
<Install>false</Install>
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Services\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using LaDOSE.DesktopApp.Services;
|
|
||||||
using LaDOSE.DTO;
|
using LaDOSE.DTO;
|
||||||
|
using LaDOSE.REST;
|
||||||
|
|
||||||
namespace LaDOSE.DesktopApp.ViewModels
|
namespace LaDOSE.DesktopApp.ViewModels
|
||||||
{
|
{
|
||||||
@@ -22,13 +23,14 @@ namespace LaDOSE.DesktopApp.ViewModels
|
|||||||
protected override void OnInitialize()
|
protected override void OnInitialize()
|
||||||
{
|
{
|
||||||
LoadGames();
|
LoadGames();
|
||||||
|
this.CurrentGame = Games.First();
|
||||||
base.OnInitialize();
|
base.OnInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadGames()
|
public void LoadGames()
|
||||||
{
|
{
|
||||||
this.Games.Clear();
|
var gameDtos = this.RestService.GetGames().OrderBy(e=>e.Order).ToList();
|
||||||
this.Games = this.RestService.GetGames();
|
this.Games = gameDtos;
|
||||||
NotifyOfPropertyChange("Games");
|
NotifyOfPropertyChange("Games");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +58,8 @@ namespace LaDOSE.DesktopApp.ViewModels
|
|||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
this.RestService.UpdateGame(this.CurrentGame);
|
this.RestService.UpdateGame(this.CurrentGame);
|
||||||
this.Games = RestService.GetGames();
|
LoadGames();
|
||||||
|
|
||||||
}
|
}
|
||||||
public void AddGame()
|
public void AddGame()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using LaDOSE.DesktopApp.Services;
|
using LaDOSE.REST;
|
||||||
|
|
||||||
namespace LaDOSE.DesktopApp.ViewModels
|
namespace LaDOSE.DesktopApp.ViewModels
|
||||||
{
|
{
|
||||||
@@ -15,6 +16,16 @@ namespace LaDOSE.DesktopApp.ViewModels
|
|||||||
this.DisplayName = "LaDOSE";
|
this.DisplayName = "LaDOSE";
|
||||||
this.AppIcon = BitmapFrame.Create(Application.GetResourceStream(new Uri("/LaDOSE.DesktopApp;component/Resources/64x64.png",
|
this.AppIcon = BitmapFrame.Create(Application.GetResourceStream(new Uri("/LaDOSE.DesktopApp;component/Resources/64x64.png",
|
||||||
UriKind.RelativeOrAbsolute)).Stream);
|
UriKind.RelativeOrAbsolute)).Stream);
|
||||||
|
|
||||||
|
var appSettings = ConfigurationManager.AppSettings;
|
||||||
|
string url = (string)appSettings["ApiUri"];
|
||||||
|
string user = (string)appSettings["ApiUser"];
|
||||||
|
string password = (string)appSettings["ApiPassword"];
|
||||||
|
Uri uri = new Uri(url);
|
||||||
|
var restService = IoC.Get<RestService>();
|
||||||
|
|
||||||
|
restService.Connect(uri, user, password);
|
||||||
|
|
||||||
var wordPressViewModel = new WordPressViewModel(IoC.Get<RestService>());
|
var wordPressViewModel = new WordPressViewModel(IoC.Get<RestService>());
|
||||||
ActivateItem(wordPressViewModel);
|
ActivateItem(wordPressViewModel);
|
||||||
base.OnInitialize();
|
base.OnInitialize();
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ using System.Windows;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using LaDOSE.DesktopApp.Services;
|
|
||||||
using LaDOSE.DesktopApp.Utils;
|
using LaDOSE.DesktopApp.Utils;
|
||||||
using LaDOSE.DTO;
|
using LaDOSE.DTO;
|
||||||
|
using LaDOSE.REST;
|
||||||
using Action = System.Action;
|
using Action = System.Action;
|
||||||
|
|
||||||
namespace LaDOSE.DesktopApp.ViewModels
|
namespace LaDOSE.DesktopApp.ViewModels
|
||||||
@@ -169,7 +169,7 @@ namespace LaDOSE.DesktopApp.ViewModels
|
|||||||
var reservation = SelectedWpEvent.WpBookings.FirstOrDefault();
|
var reservation = SelectedWpEvent.WpBookings.FirstOrDefault();
|
||||||
var games = WpEventDeserialize.Parse(reservation.Meta);
|
var games = WpEventDeserialize.Parse(reservation.Meta);
|
||||||
GamesFound.Clear();
|
GamesFound.Clear();
|
||||||
|
var foundGames = new List<GameDTO>();
|
||||||
if (games != null)
|
if (games != null)
|
||||||
{
|
{
|
||||||
foreach (string wpTag in games.Select(e => e.Name))
|
foreach (string wpTag in games.Select(e => e.Name))
|
||||||
@@ -178,14 +178,20 @@ namespace LaDOSE.DesktopApp.ViewModels
|
|||||||
e.WordPressTag != null && e.WordPressTag.Split(';').Contains(wpTag));
|
e.WordPressTag != null && e.WordPressTag.Split(';').Contains(wpTag));
|
||||||
if (foundGame != null)
|
if (foundGame != null)
|
||||||
{
|
{
|
||||||
if (!GamesFound.Contains(foundGame))
|
if (!foundGames.Contains(foundGame))
|
||||||
{
|
{
|
||||||
GamesFound.Add(foundGame);
|
foundGames.Add(foundGame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var orderedEnumerable = foundGames.OrderBy(e => e.Order);
|
||||||
|
foreach (var gameDto in orderedEnumerable)
|
||||||
|
{
|
||||||
|
GamesFound.Add(gameDto);
|
||||||
|
}
|
||||||
|
|
||||||
NotifyOfPropertyChange(() => GamesFound);
|
NotifyOfPropertyChange(() => GamesFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,8 +215,9 @@ namespace LaDOSE.DesktopApp.ViewModels
|
|||||||
System.Windows.Input.Mouse.OverrideCursor = Cursors.Wait);
|
System.Windows.Input.Mouse.OverrideCursor = Cursors.Wait);
|
||||||
GamesFound = new ObservableCollection<GameDTO>();
|
GamesFound = new ObservableCollection<GameDTO>();
|
||||||
this.Games = this.RestService.GetGames();
|
this.Games = this.RestService.GetGames();
|
||||||
this.Events = this.RestService.GetEvents();
|
var events = this.RestService.GetEvents();
|
||||||
|
events.ForEach(e => e.WpBookings = e.WpBookings.OrderBy(x => x.WpUser.Name).ToList());
|
||||||
|
this.Events = events;
|
||||||
NotifyOfPropertyChange("Events");
|
NotifyOfPropertyChange("Events");
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
System.Windows.Input.Mouse.OverrideCursor = null);
|
System.Windows.Input.Mouse.OverrideCursor = null);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:LaDOSE.DesktopApp.Views"
|
xmlns:local="clr-namespace:LaDOSE.DesktopApp.Views"
|
||||||
|
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||||
|
xmlns:behaviors="clr-namespace:LaDOSE.DesktopApp.Behaviors"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
<Grid Row="4" Column="1">
|
<Grid Row="4" Column="1">
|
||||||
@@ -19,7 +21,7 @@
|
|||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Label Content="{Binding Id}"></Label>
|
<Label Content="{Binding Order}"></Label>
|
||||||
<Label> - </Label>
|
<Label> - </Label>
|
||||||
<Label Content="{Binding Name}"></Label>
|
<Label Content="{Binding Name}"></Label>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -37,6 +39,7 @@
|
|||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
<RowDefinition Height="*"></RowDefinition>
|
<RowDefinition Height="*"></RowDefinition>
|
||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
<RowDefinition Height="*"></RowDefinition>
|
<RowDefinition Height="*"></RowDefinition>
|
||||||
@@ -51,11 +54,20 @@
|
|||||||
<Label Grid.Row="2" Grid.Column="0">Name</Label>
|
<Label Grid.Row="2" Grid.Column="0">Name</Label>
|
||||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Path=CurrentGame.Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ></TextBox>
|
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Path=CurrentGame.Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ></TextBox>
|
||||||
|
|
||||||
<Label Grid.Row="3" Grid.Column="0">WpTag</Label>
|
<Label Grid.Row="3" Grid.Column="0">Order</Label>
|
||||||
<TextBox Grid.Row="4" Grid.ColumnSpan="2" Text="{Binding Path=CurrentGame.WordPressTag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ></TextBox>
|
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=CurrentGame.Order,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
|
||||||
<Label Grid.Row="5" Grid.Column="0">WpTagOs</Label>
|
<i:Interaction.Behaviors>
|
||||||
<TextBox Grid.Row="6" Grid.ColumnSpan="2" Text="{Binding Path=CurrentGame.WordPressTagOs,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ></TextBox>
|
<behaviors:TextBoxInputRegExBehaviour RegularExpression="^\d+$" MaxLength="9" EmptyValue="0">
|
||||||
<Button Grid.Row="7" Grid.ColumnSpan="2" x:Name="Update">Update</Button>
|
|
||||||
|
</behaviors:TextBoxInputRegExBehaviour>
|
||||||
|
</i:Interaction.Behaviors>
|
||||||
|
</TextBox>
|
||||||
|
|
||||||
|
<Label Grid.Row="4" Grid.Column="0">WpTag</Label>
|
||||||
|
<TextBox Grid.Row="5" Grid.ColumnSpan="2" Text="{Binding Path=CurrentGame.WordPressTag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ></TextBox>
|
||||||
|
<Label Grid.Row="6" Grid.Column="0">WpTagOs</Label>
|
||||||
|
<TextBox Grid.Row="7" Grid.ColumnSpan="2" Text="{Binding Path=CurrentGame.WordPressTagOs,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ></TextBox>
|
||||||
|
<Button Grid.Row="8" Grid.ColumnSpan="2" x:Name="Update">Update</Button>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="Caliburn.Micro" version="3.2.0" targetFramework="net461" />
|
<package id="Caliburn.Micro" version="3.2.0" targetFramework="net461" />
|
||||||
<package id="Caliburn.Micro.Core" version="3.2.0" targetFramework="net461" />
|
<package id="Caliburn.Micro.Core" version="3.2.0" targetFramework="net461" />
|
||||||
<package id="RestSharp" version="106.6.5" targetFramework="net461" />
|
<package id="RestSharp" version="106.6.9" targetFramework="net461" />
|
||||||
<package id="WPFThemes.DarkBlend" version="1.0.8" targetFramework="net461" />
|
<package id="WPFThemes.DarkBlend" version="1.0.8" targetFramework="net461" />
|
||||||
</packages>
|
</packages>
|
||||||
@@ -4,32 +4,50 @@ using DSharpPlus.CommandsNext.Attributes;
|
|||||||
|
|
||||||
namespace LaDOSE.DiscordBot.Command
|
namespace LaDOSE.DiscordBot.Command
|
||||||
{
|
{
|
||||||
|
internal class Result
|
||||||
|
{
|
||||||
|
Dependencies dep;
|
||||||
|
|
||||||
internal class Result
|
public Result(Dependencies d)
|
||||||
{
|
{
|
||||||
Dependencies dep;
|
this.dep = d;
|
||||||
public Result(Dependencies d)
|
|
||||||
{
|
|
||||||
this.dep = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[RequireRolesAttribute("Staff")]
|
|
||||||
[Command("update")]
|
|
||||||
public async Task UpdateAsync(CommandContext ctx)
|
|
||||||
{
|
|
||||||
var tournament = await dep.ChallongeService.GetLastTournament();
|
|
||||||
await ctx.RespondAsync($"Mise à jour effectuée");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("last")]
|
|
||||||
public async Task LastAsync(CommandContext ctx)
|
|
||||||
{
|
|
||||||
var lastTournamentMessage = dep.ChallongeService.GetLastTournamentMessage();
|
|
||||||
await ctx.RespondAsync(lastTournamentMessage);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[RequireRolesAttribute("Staff")]
|
||||||
|
[Command("update")]
|
||||||
|
public async Task UpdateAsync(CommandContext ctx)
|
||||||
|
{
|
||||||
|
var tournament = await dep.ChallongeService.GetLastTournament();
|
||||||
|
await ctx.RespondAsync($"Mise à jour effectuée");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("last")]
|
||||||
|
public async Task LastAsync(CommandContext ctx)
|
||||||
|
{
|
||||||
|
var lastTournamentMessage = dep.ChallongeService.GetLastTournamentMessage();
|
||||||
|
await ctx.RespondAsync(lastTournamentMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RequireRolesAttribute("Staff")]
|
||||||
|
[Command("inscriptions")]
|
||||||
|
public async Task InscriptionsAsync(CommandContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
var inscrits = dep.WebService.GetInscrits();
|
||||||
|
await ctx.RespondAsync(inscrits);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RequireRolesAttribute("Staff")]
|
||||||
|
[Command("UpdateDb")]
|
||||||
|
public async Task UpdateDbAsync(CommandContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.RespondAsync("Mise à jour des inscriptions en cours...");
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
|
||||||
|
var status = dep.WebService.RefreshDb() ? "Ok" : "erreur";
|
||||||
|
|
||||||
|
await ctx.RespondAsync($"Status: {status}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,6 @@ namespace LaDOSE.DiscordBot
|
|||||||
internal CancellationTokenSource Cts { get; set; }
|
internal CancellationTokenSource Cts { get; set; }
|
||||||
public ChallongeService ChallongeService { get; set; }
|
public ChallongeService ChallongeService { get; set; }
|
||||||
public TodoService TodoService { get; set; }
|
public TodoService TodoService { get; set; }
|
||||||
|
public WebService WebService { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,10 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\LaDOSE.REST\LaDOSE.REST.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="ChallongeCSharpDriver">
|
<Reference Include="ChallongeCSharpDriver">
|
||||||
<HintPath>..\..\Library\ChallongeCSharpDriver.dll</HintPath>
|
<HintPath>..\..\Library\ChallongeCSharpDriver.dll</HintPath>
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ namespace LaDOSE.DiscordBot
|
|||||||
|
|
||||||
var discordToken = builder["Discord:Token"].ToString();
|
var discordToken = builder["Discord:Token"].ToString();
|
||||||
var challongeToken = builder["Challonge:Token"].ToString();
|
var challongeToken = builder["Challonge:Token"].ToString();
|
||||||
|
var restUrl = builder["REST:Url"].ToString();
|
||||||
|
var restUser = builder["REST:User"].ToString();
|
||||||
|
var restPassword = builder["REST:Password"].ToString();
|
||||||
|
|
||||||
Console.WriteLine($"LaDOSE.Net Discord Bot");
|
Console.WriteLine($"LaDOSE.Net Discord Bot");
|
||||||
|
|
||||||
@@ -42,7 +44,7 @@ namespace LaDOSE.DiscordBot
|
|||||||
TokenType = TokenType.Bot
|
TokenType = TokenType.Bot
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var webService = new WebService(new Uri(restUrl),restUser,restPassword);
|
||||||
var challongeService = new ChallongeService(challongeToken);
|
var challongeService = new ChallongeService(challongeToken);
|
||||||
var todoService = new TodoService();
|
var todoService = new TodoService();
|
||||||
var cts = new CancellationTokenSource();
|
var cts = new CancellationTokenSource();
|
||||||
@@ -56,6 +58,7 @@ namespace LaDOSE.DiscordBot
|
|||||||
Cts = cts,
|
Cts = cts,
|
||||||
ChallongeService = challongeService,
|
ChallongeService = challongeService,
|
||||||
TodoService = todoService,
|
TodoService = todoService,
|
||||||
|
WebService = webService
|
||||||
});
|
});
|
||||||
dep = d.Build();
|
dep = d.Build();
|
||||||
}
|
}
|
||||||
|
|||||||
41
LaDOSE.Src/LaDOSE.DiscordBot/Service/WebService.cs
Normal file
41
LaDOSE.Src/LaDOSE.DiscordBot/Service/WebService.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ChallongeCSharpDriver;
|
||||||
|
using ChallongeCSharpDriver.Caller;
|
||||||
|
using ChallongeCSharpDriver.Core.Queries;
|
||||||
|
using ChallongeCSharpDriver.Core.Results;
|
||||||
|
using ChallongeCSharpDriver.Main;
|
||||||
|
using ChallongeCSharpDriver.Main.Objects;
|
||||||
|
using LaDOSE.DTO;
|
||||||
|
using LaDOSE.REST;
|
||||||
|
|
||||||
|
namespace LaDOSE.DiscordBot.Service
|
||||||
|
{
|
||||||
|
public class WebService
|
||||||
|
{
|
||||||
|
private RestService restService;
|
||||||
|
|
||||||
|
public WebService(Uri uri,string user,string password)
|
||||||
|
{
|
||||||
|
restService = new RestService();
|
||||||
|
restService.Connect(uri,user,password);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String GetInscrits()
|
||||||
|
{
|
||||||
|
var wpEventDto = restService.GetNextEvent();
|
||||||
|
var wpBookingDtos = wpEventDto.WpBookings;
|
||||||
|
List<String> player= new List<string>();
|
||||||
|
wpBookingDtos.OrderBy(e=>e.WpUser.Name).ToList().ForEach(e=> player.Add(e.WpUser.Name));
|
||||||
|
return $"Les Joueurs inscrits pour {wpEventDto.Name} {string.Join(", ", player)}";
|
||||||
|
}
|
||||||
|
public bool RefreshDb()
|
||||||
|
{
|
||||||
|
return restService.RefreshDb();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ namespace LaDOSE.Entity
|
|||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string ImgUrl { get; set; }
|
public string ImgUrl { get; set; }
|
||||||
|
public int Order { get; set; }
|
||||||
public string WordPressTag { get; set; }
|
public string WordPressTag { get; set; }
|
||||||
public string WordPressTagOs { get; set; }
|
public string WordPressTagOs { get; set; }
|
||||||
public virtual IEnumerable<SeasonGame> Seasons { get; set; }
|
public virtual IEnumerable<SeasonGame> Seasons { get; set; }
|
||||||
|
|||||||
15
LaDOSE.Src/LaDOSE.REST/LaDOSE.REST.csproj
Normal file
15
LaDOSE.Src/LaDOSE.REST/LaDOSE.REST.csproj
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="RestSharp" Version="106.6.9" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\LaDOSE.DTO\LaDOSE.DTO.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -1,32 +1,25 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Configuration;
|
|
||||||
using System.Windows;
|
|
||||||
using LaDOSE.DTO;
|
using LaDOSE.DTO;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
using RestSharp.Authenticators;
|
using RestSharp.Authenticators;
|
||||||
using RestSharp.Serialization.Json;
|
using RestSharp.Serialization.Json;
|
||||||
using DataFormat = RestSharp.DataFormat;
|
|
||||||
|
|
||||||
namespace LaDOSE.DesktopApp.Services
|
namespace LaDOSE.REST
|
||||||
{
|
{
|
||||||
public class RestService
|
public class RestService
|
||||||
{
|
{
|
||||||
|
|
||||||
public RestClient Client { get; set; }
|
public RestClient Client { get; set; }
|
||||||
|
|
||||||
public RestService()
|
public RestService() { }
|
||||||
|
|
||||||
|
|
||||||
|
public void Connect(Uri url, string user, string password)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
MessageBox.Show("WAIT");
|
|
||||||
#endif
|
|
||||||
var appSettings = ConfigurationManager.AppSettings;
|
|
||||||
string url = (string) appSettings["ApiUri"];
|
|
||||||
string user = (string)appSettings["ApiUser"];
|
|
||||||
string password = (string) appSettings["ApiPassword"];
|
|
||||||
Client = new RestClient(url);
|
Client = new RestClient(url);
|
||||||
var restRequest = new RestRequest("users/auth", Method.POST);
|
var restRequest = new RestRequest("users/auth", Method.POST);
|
||||||
restRequest.AddJsonBody(new { username = user, password = password });
|
restRequest.AddJsonBody(new {username = user, password = password});
|
||||||
var response = Client.Post(restRequest);
|
var response = Client.Post(restRequest);
|
||||||
if (response.IsSuccessful)
|
if (response.IsSuccessful)
|
||||||
{
|
{
|
||||||
@@ -36,8 +29,7 @@ namespace LaDOSE.DesktopApp.Services
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Unable to contact services, i m useless, BYEKTHX","Error",MessageBoxButton.OK,MessageBoxImage.Error);
|
throw new Exception("unable to contact services");
|
||||||
Application.Current.Shutdown(-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +95,12 @@ namespace LaDOSE.DesktopApp.Services
|
|||||||
var restResponse = Client.Get<List<WPEventDTO>>(restRequest);
|
var restResponse = Client.Get<List<WPEventDTO>>(restRequest);
|
||||||
return restResponse.Data;
|
return restResponse.Data;
|
||||||
}
|
}
|
||||||
|
public WPEventDTO GetNextEvent()
|
||||||
|
{
|
||||||
|
var restRequest = new RestRequest("/api/wordpress/NextEvent", Method.GET);
|
||||||
|
var restResponse = Client.Get<WPEventDTO>(restRequest);
|
||||||
|
return restResponse.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public string CreateChallonge(int gameId, int eventId)
|
public string CreateChallonge(int gameId, int eventId)
|
||||||
@@ -6,6 +6,7 @@ namespace LaDOSE.Business.Interface
|
|||||||
{
|
{
|
||||||
public interface IWordPressService
|
public interface IWordPressService
|
||||||
{
|
{
|
||||||
|
WPEvent GetNextWpEvent();
|
||||||
List<WPEvent> GetWpEvent();
|
List<WPEvent> GetWpEvent();
|
||||||
List<WPUser> GetBooking(int wpEventId, Game game);
|
List<WPUser> GetBooking(int wpEventId, Game game);
|
||||||
List<WPUser> GetBookingOptions(int wpEventId, Game game);
|
List<WPUser> GetBookingOptions(int wpEventId, Game game);
|
||||||
|
|||||||
@@ -15,11 +15,25 @@ namespace LaDOSE.Business.Service
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Game AddOrUpdate(Game entity)
|
||||||
|
{
|
||||||
|
if (entity.Order == 0)
|
||||||
|
{
|
||||||
|
entity.Order = GetNextFreeOrder();
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.AddOrUpdate(entity);
|
||||||
|
}
|
||||||
|
|
||||||
public override IEnumerable<Game> GetAll()
|
public override IEnumerable<Game> GetAll()
|
||||||
{
|
{
|
||||||
return _context.Game.Include(e => e.Seasons).ThenInclude(e=>e.Season).ToList();
|
return _context.Game.Include(e => e.Seasons).ThenInclude(e=>e.Season).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetNextFreeOrder()
|
||||||
|
{
|
||||||
|
int nextFreeOrder = _context.Game.Max(e => e.Order);
|
||||||
|
return ++nextFreeOrder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,12 @@ namespace LaDOSE.Business.Service
|
|||||||
.ThenInclude(e => e.WPUser).Where(e => e.WPBookings.Count() != 0).Take(10).ToList();
|
.ThenInclude(e => e.WPUser).Where(e => e.WPBookings.Count() != 0).Take(10).ToList();
|
||||||
return wpEvents;
|
return wpEvents;
|
||||||
}
|
}
|
||||||
|
public WPEvent GetNextWpEvent()
|
||||||
|
{
|
||||||
|
var wpEvents = _context.Set<WPEvent>().OrderByDescending(e=>e.Date).ThenByDescending(e => e.Id)
|
||||||
|
.Include(e => e.WPBookings).ThenInclude(e => e.WPUser).FirstOrDefault(e => Enumerable.Count<WPBooking>(e.WPBookings) != 0);
|
||||||
|
return wpEvents;
|
||||||
|
}
|
||||||
|
|
||||||
public bool UpdateBooking()
|
public bool UpdateBooking()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bot", "Bot", "{8B9C38FB-2A8
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "Setup\Setup.vdproj", "{6825F5F4-EBB5-469F-B935-5B916EA37ACC}"
|
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "Setup\Setup.vdproj", "{6825F5F4-EBB5-469F-B935-5B916EA37ACC}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utils", "Utils", "{2A0E1491-8E15-4062-ABE7-C04AE9655515}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaDOSE.REST", "LaDOSE.REST\LaDOSE.REST.csproj", "{692C2A72-AB7E-4502-BED8-AA2AFA1761CB}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -55,6 +59,10 @@ Global
|
|||||||
{61201DA6-1BC9-4BA1-AC45-70104D391ECD}.Release|Any CPU.Build.0 = Release|Any CPU
|
{61201DA6-1BC9-4BA1-AC45-70104D391ECD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{6825F5F4-EBB5-469F-B935-5B916EA37ACC}.Debug|Any CPU.ActiveCfg = Debug
|
{6825F5F4-EBB5-469F-B935-5B916EA37ACC}.Debug|Any CPU.ActiveCfg = Debug
|
||||||
{6825F5F4-EBB5-469F-B935-5B916EA37ACC}.Release|Any CPU.ActiveCfg = Release
|
{6825F5F4-EBB5-469F-B935-5B916EA37ACC}.Release|Any CPU.ActiveCfg = Release
|
||||||
|
{692C2A72-AB7E-4502-BED8-AA2AFA1761CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{692C2A72-AB7E-4502-BED8-AA2AFA1761CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{692C2A72-AB7E-4502-BED8-AA2AFA1761CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{692C2A72-AB7E-4502-BED8-AA2AFA1761CB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -67,6 +75,7 @@ Global
|
|||||||
{A76AC851-4D43-4BF9-9034-F496888ADAFD} = {DD52FE00-B822-4DE3-B369-2BFB5F808130}
|
{A76AC851-4D43-4BF9-9034-F496888ADAFD} = {DD52FE00-B822-4DE3-B369-2BFB5F808130}
|
||||||
{61201DA6-1BC9-4BA1-AC45-70104D391ECD} = {6FC9438E-D93E-4E63-9342-F8A966EE2D06}
|
{61201DA6-1BC9-4BA1-AC45-70104D391ECD} = {6FC9438E-D93E-4E63-9342-F8A966EE2D06}
|
||||||
{6825F5F4-EBB5-469F-B935-5B916EA37ACC} = {DD52FE00-B822-4DE3-B369-2BFB5F808130}
|
{6825F5F4-EBB5-469F-B935-5B916EA37ACC} = {DD52FE00-B822-4DE3-B369-2BFB5F808130}
|
||||||
|
{692C2A72-AB7E-4502-BED8-AA2AFA1761CB} = {2A0E1491-8E15-4062-ABE7-C04AE9655515}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {D47DEDD0-C906-439D-81E4-D86BBE723B8C}
|
SolutionGuid = {D47DEDD0-C906-439D-81E4-D86BBE723B8C}
|
||||||
|
|||||||
Reference in New Issue
Block a user