Player now resolve in UI
This commit is contained in:
@@ -64,9 +64,15 @@ namespace LaDOSE.Api.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("CreateChallonge/{gameId:int}/{wpEventId:int}")]
|
||||
public bool CreateChallonge(int gameId, int wpEventId)
|
||||
public string CreateChallonge(int gameId, int wpEventId)
|
||||
{
|
||||
return _service.CreateChallonge(gameId, wpEventId);
|
||||
return _service.CreateChallonge(gameId, wpEventId,null);
|
||||
}
|
||||
|
||||
[HttpPost("CreateChallonge/{gameId:int}/{wpEventId:int}")]
|
||||
public string CreateChallonge(int gameId, int wpEventId, [FromBody]List<WPUser> additionalPlayer)
|
||||
{
|
||||
return _service.CreateChallonge(gameId, wpEventId, additionalPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,18 +14,4 @@ namespace LaDOSE.DTO
|
||||
public DateTime? Date { get; set; }
|
||||
public List<WPBooking> WpBookings { get; set; }
|
||||
}
|
||||
|
||||
public class WPBooking
|
||||
{
|
||||
public WPUser WpUser { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public string Meta { get; set; }
|
||||
}
|
||||
|
||||
public class WPUser
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
8
LaDOSE.Src/LaDOSE.DTO/WPUser.cs
Normal file
8
LaDOSE.Src/LaDOSE.DTO/WPUser.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace LaDOSE.DTO
|
||||
{
|
||||
public class WPUser
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
11
LaDOSE.Src/LaDOSE.DTO/WpBooking.cs
Normal file
11
LaDOSE.Src/LaDOSE.DTO/WpBooking.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace LaDOSE.DTO
|
||||
{
|
||||
public class WPBooking
|
||||
{
|
||||
public WPUser WpUser { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public string Meta { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary>
|
||||
<local:Bootstrapper x:Key="Bootstrapper" />
|
||||
<local:Bootstrapper x:Key="Bootstrapper" />
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -0,0 +1,418 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
|
||||
namespace LaDOSE.DesktopApp.Behaviors
|
||||
{
|
||||
/// <summary>
|
||||
/// A sync behaviour for a multiselector.
|
||||
/// </summary>
|
||||
public static class MultiSelectorBehaviours
|
||||
{
|
||||
public static readonly DependencyProperty SynchronizedSelectedItems = DependencyProperty.RegisterAttached(
|
||||
"SynchronizedSelectedItems", typeof(IList), typeof(MultiSelectorBehaviours), new PropertyMetadata(null, OnSynchronizedSelectedItemsChanged));
|
||||
|
||||
private static readonly DependencyProperty SynchronizationManagerProperty = DependencyProperty.RegisterAttached(
|
||||
"SynchronizationManager", typeof(SynchronizationManager), typeof(MultiSelectorBehaviours), new PropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the synchronized selected items.
|
||||
/// </summary>
|
||||
/// <param name="dependencyObject">The dependency object.</param>
|
||||
/// <returns>The list that is acting as the sync list.</returns>
|
||||
public static IList GetSynchronizedSelectedItems(DependencyObject dependencyObject)
|
||||
{
|
||||
return (IList)dependencyObject.GetValue(SynchronizedSelectedItems);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the synchronized selected items.
|
||||
/// </summary>
|
||||
/// <param name="dependencyObject">The dependency object.</param>
|
||||
/// <param name="value">The value to be set as synchronized items.</param>
|
||||
public static void SetSynchronizedSelectedItems(DependencyObject dependencyObject, IList value)
|
||||
{
|
||||
dependencyObject.SetValue(SynchronizedSelectedItems, value);
|
||||
}
|
||||
|
||||
private static SynchronizationManager GetSynchronizationManager(DependencyObject dependencyObject)
|
||||
{
|
||||
return (SynchronizationManager)dependencyObject.GetValue(SynchronizationManagerProperty);
|
||||
}
|
||||
|
||||
private static void SetSynchronizationManager(DependencyObject dependencyObject, SynchronizationManager value)
|
||||
{
|
||||
dependencyObject.SetValue(SynchronizationManagerProperty, value);
|
||||
}
|
||||
|
||||
private static void OnSynchronizedSelectedItemsChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.OldValue != null)
|
||||
{
|
||||
SynchronizationManager synchronizer = GetSynchronizationManager(dependencyObject);
|
||||
synchronizer.StopSynchronizing();
|
||||
|
||||
SetSynchronizationManager(dependencyObject, null);
|
||||
}
|
||||
|
||||
IList list = e.NewValue as IList;
|
||||
Selector selector = dependencyObject as Selector;
|
||||
|
||||
// check that this property is an IList, and that it is being set on a ListBox
|
||||
if (list != null && selector != null)
|
||||
{
|
||||
SynchronizationManager synchronizer = GetSynchronizationManager(dependencyObject);
|
||||
if (synchronizer == null)
|
||||
{
|
||||
synchronizer = new SynchronizationManager(selector);
|
||||
SetSynchronizationManager(dependencyObject, synchronizer);
|
||||
}
|
||||
|
||||
synchronizer.StartSynchronizingList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A synchronization manager.
|
||||
/// </summary>
|
||||
private class SynchronizationManager
|
||||
{
|
||||
private readonly Selector _multiSelector;
|
||||
private TwoListSynchronizer _synchronizer;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SynchronizationManager"/> class.
|
||||
/// </summary>
|
||||
/// <param name="selector">The selector.</param>
|
||||
internal SynchronizationManager(Selector selector)
|
||||
{
|
||||
_multiSelector = selector;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts synchronizing the list.
|
||||
/// </summary>
|
||||
public void StartSynchronizingList()
|
||||
{
|
||||
IList list = GetSynchronizedSelectedItems(_multiSelector);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
_synchronizer = new TwoListSynchronizer(GetSelectedItemsCollection(_multiSelector), list);
|
||||
_synchronizer.StartSynchronizing();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops synchronizing the list.
|
||||
/// </summary>
|
||||
public void StopSynchronizing()
|
||||
{
|
||||
_synchronizer.StopSynchronizing();
|
||||
}
|
||||
|
||||
public static IList GetSelectedItemsCollection(Selector selector)
|
||||
{
|
||||
if (selector is MultiSelector)
|
||||
{
|
||||
return (selector as MultiSelector).SelectedItems;
|
||||
}
|
||||
else if (selector is ListBox)
|
||||
{
|
||||
return (selector as ListBox).SelectedItems;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Target object has no SelectedItems property to bind.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class TwoListSynchronizer : IWeakEventListener
|
||||
{
|
||||
private static readonly IListItemConverter DefaultConverter = new DoNothingListItemConverter();
|
||||
private readonly IList _masterList;
|
||||
private readonly IListItemConverter _masterTargetConverter;
|
||||
private readonly IList _targetList;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TwoListSynchronizer"/> class.
|
||||
/// </summary>
|
||||
/// <param name="masterList">The master list.</param>
|
||||
/// <param name="targetList">The target list.</param>
|
||||
/// <param name="masterTargetConverter">The master-target converter.</param>
|
||||
public TwoListSynchronizer(IList masterList, IList targetList, IListItemConverter masterTargetConverter)
|
||||
{
|
||||
_masterList = masterList;
|
||||
_targetList = targetList;
|
||||
_masterTargetConverter = masterTargetConverter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TwoListSynchronizer"/> class.
|
||||
/// </summary>
|
||||
/// <param name="masterList">The master list.</param>
|
||||
/// <param name="targetList">The target list.</param>
|
||||
public TwoListSynchronizer(IList masterList, IList targetList)
|
||||
: this(masterList, targetList, DefaultConverter)
|
||||
{
|
||||
}
|
||||
|
||||
private delegate void ChangeListAction(IList list, NotifyCollectionChangedEventArgs e, Converter<object, object> converter);
|
||||
|
||||
/// <summary>
|
||||
/// Starts synchronizing the lists.
|
||||
/// </summary>
|
||||
public void StartSynchronizing()
|
||||
{
|
||||
ListenForChangeEvents(_masterList);
|
||||
ListenForChangeEvents(_targetList);
|
||||
|
||||
// Update the Target list from the Master list
|
||||
SetListValuesFromSource(_masterList, _targetList, ConvertFromMasterToTarget);
|
||||
|
||||
// In some cases the target list might have its own view on which items should included:
|
||||
// so update the master list from the target list
|
||||
// (This is the case with a ListBox SelectedItems collection: only items from the ItemsSource can be included in SelectedItems)
|
||||
if (!TargetAndMasterCollectionsAreEqual())
|
||||
{
|
||||
SetListValuesFromSource(_targetList, _masterList, ConvertFromTargetToMaster);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop synchronizing the lists.
|
||||
/// </summary>
|
||||
public void StopSynchronizing()
|
||||
{
|
||||
StopListeningForChangeEvents(_masterList);
|
||||
StopListeningForChangeEvents(_targetList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Receives events from the centralized event manager.
|
||||
/// </summary>
|
||||
/// <param name="managerType">The type of the <see cref="T:System.Windows.WeakEventManager"/> calling this method.</param>
|
||||
/// <param name="sender">Object that originated the event.</param>
|
||||
/// <param name="e">Event data.</param>
|
||||
/// <returns>
|
||||
/// true if the listener handled the event. It is considered an error by the <see cref="T:System.Windows.WeakEventManager"/> handling in WPF to register a listener for an event that the listener does not handle. Regardless, the method should return false if it receives an event that it does not recognize or handle.
|
||||
/// </returns>
|
||||
public bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
|
||||
{
|
||||
HandleCollectionChanged(sender as IList, e as NotifyCollectionChangedEventArgs);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Listens for change events on a list.
|
||||
/// </summary>
|
||||
/// <param name="list">The list to listen to.</param>
|
||||
protected void ListenForChangeEvents(IList list)
|
||||
{
|
||||
if (list is INotifyCollectionChanged)
|
||||
{
|
||||
CollectionChangedEventManager.AddListener(list as INotifyCollectionChanged, this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops listening for change events.
|
||||
/// </summary>
|
||||
/// <param name="list">The list to stop listening to.</param>
|
||||
protected void StopListeningForChangeEvents(IList list)
|
||||
{
|
||||
if (list is INotifyCollectionChanged)
|
||||
{
|
||||
CollectionChangedEventManager.RemoveListener(list as INotifyCollectionChanged, this);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddItems(IList list, NotifyCollectionChangedEventArgs e, Converter<object, object> converter)
|
||||
{
|
||||
int itemCount = e.NewItems.Count;
|
||||
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
{
|
||||
int insertionPoint = e.NewStartingIndex + i;
|
||||
|
||||
if (insertionPoint > list.Count)
|
||||
{
|
||||
list.Add(converter(e.NewItems[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Insert(insertionPoint, converter(e.NewItems[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private object ConvertFromMasterToTarget(object masterListItem)
|
||||
{
|
||||
return _masterTargetConverter == null ? masterListItem : _masterTargetConverter.Convert(masterListItem);
|
||||
}
|
||||
|
||||
private object ConvertFromTargetToMaster(object targetListItem)
|
||||
{
|
||||
return _masterTargetConverter == null ? targetListItem : _masterTargetConverter.ConvertBack(targetListItem);
|
||||
}
|
||||
|
||||
private void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
IList sourceList = sender as IList;
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
PerformActionOnAllLists(AddItems, sourceList, e);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Move:
|
||||
PerformActionOnAllLists(MoveItems, sourceList, e);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
PerformActionOnAllLists(RemoveItems, sourceList, e);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Replace:
|
||||
PerformActionOnAllLists(ReplaceItems, sourceList, e);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
UpdateListsFromSource(sender as IList);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveItems(IList list, NotifyCollectionChangedEventArgs e, Converter<object, object> converter)
|
||||
{
|
||||
RemoveItems(list, e, converter);
|
||||
AddItems(list, e, converter);
|
||||
}
|
||||
|
||||
private void PerformActionOnAllLists(ChangeListAction action, IList sourceList, NotifyCollectionChangedEventArgs collectionChangedArgs)
|
||||
{
|
||||
if (sourceList == _masterList)
|
||||
{
|
||||
PerformActionOnList(_targetList, action, collectionChangedArgs, ConvertFromMasterToTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
PerformActionOnList(_masterList, action, collectionChangedArgs, ConvertFromTargetToMaster);
|
||||
}
|
||||
}
|
||||
|
||||
private void PerformActionOnList(IList list, ChangeListAction action, NotifyCollectionChangedEventArgs collectionChangedArgs, Converter<object, object> converter)
|
||||
{
|
||||
StopListeningForChangeEvents(list);
|
||||
action(list, collectionChangedArgs, converter);
|
||||
ListenForChangeEvents(list);
|
||||
}
|
||||
|
||||
private void RemoveItems(IList list, NotifyCollectionChangedEventArgs e, Converter<object, object> converter)
|
||||
{
|
||||
int itemCount = e.OldItems.Count;
|
||||
|
||||
// for the number of items being removed, remove the item from the Old Starting Index
|
||||
// (this will cause following items to be shifted down to fill the hole).
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
{
|
||||
list.RemoveAt(e.OldStartingIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReplaceItems(IList list, NotifyCollectionChangedEventArgs e, Converter<object, object> converter)
|
||||
{
|
||||
RemoveItems(list, e, converter);
|
||||
AddItems(list, e, converter);
|
||||
}
|
||||
|
||||
private void SetListValuesFromSource(IList sourceList, IList targetList, Converter<object, object> converter)
|
||||
{
|
||||
StopListeningForChangeEvents(targetList);
|
||||
|
||||
targetList.Clear();
|
||||
|
||||
foreach (object o in sourceList)
|
||||
{
|
||||
targetList.Add(converter(o));
|
||||
}
|
||||
|
||||
ListenForChangeEvents(targetList);
|
||||
}
|
||||
|
||||
private bool TargetAndMasterCollectionsAreEqual()
|
||||
{
|
||||
return _masterList.Cast<object>().SequenceEqual(_targetList.Cast<object>().Select(item => ConvertFromTargetToMaster(item)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes sure that all synchronized lists have the same values as the source list.
|
||||
/// </summary>
|
||||
/// <param name="sourceList">The source list.</param>
|
||||
private void UpdateListsFromSource(IList sourceList)
|
||||
{
|
||||
if (sourceList == _masterList)
|
||||
{
|
||||
SetListValuesFromSource(_masterList, _targetList, ConvertFromMasterToTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetListValuesFromSource(_targetList, _masterList, ConvertFromTargetToMaster);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// An implementation that does nothing in the conversions.
|
||||
/// </summary>
|
||||
internal class DoNothingListItemConverter : IListItemConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the specified master list item.
|
||||
/// </summary>
|
||||
/// <param name="masterListItem">The master list item.</param>
|
||||
/// <returns>The result of the conversion.</returns>
|
||||
public object Convert(object masterListItem)
|
||||
{
|
||||
return masterListItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the specified target list item.
|
||||
/// </summary>
|
||||
/// <param name="targetListItem">The target list item.</param>
|
||||
/// <returns>The result of the conversion.</returns>
|
||||
public object ConvertBack(object targetListItem)
|
||||
{
|
||||
return targetListItem;
|
||||
}
|
||||
}
|
||||
public interface IListItemConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the specified master list item.
|
||||
/// </summary>
|
||||
/// <param name="masterListItem">The master list item.</param>
|
||||
/// <returns>The result of the conversion.</returns>
|
||||
object Convert(object masterListItem);
|
||||
|
||||
/// <summary>
|
||||
/// Converts the specified target list item.
|
||||
/// </summary>
|
||||
/// <param name="targetListItem">The target list item.</param>
|
||||
/// <returns>The result of the conversion.</returns>
|
||||
object ConvertBack(object targetListItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,13 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>LaDOSE.DesktopApp</RootNamespace>
|
||||
<AssemblyName>LaDOSE.DesktopApp</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -50,7 +51,11 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -72,6 +77,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Behaviors\MultiSelectorBehaviours.cs" />
|
||||
<Compile Include="Bootstrapper.cs" />
|
||||
<Compile Include="Utils\PhpSerialize.cs" />
|
||||
<Compile Include="Services\RestService.cs" />
|
||||
@@ -82,15 +88,19 @@
|
||||
<Compile Include="Utils\WpfUtil.cs" />
|
||||
<Compile Include="ViewModels\ShellViewModel.cs" />
|
||||
<Compile Include="ViewModels\GameViewModel.cs" />
|
||||
<Compile Include="ViewModels\WebNavigationViewModel.cs" />
|
||||
<Compile Include="ViewModels\WordPressViewModel.cs" />
|
||||
<Compile Include="Views\WebNavigationView.xaml.cs">
|
||||
<DependentUpon>WebNavigationView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ShellView.xaml.cs">
|
||||
<DependentUpon>ShellView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\GameView.xaml.cs">
|
||||
<DependentUpon>GameView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\WpView.xaml.cs">
|
||||
<DependentUpon>WpView.xaml</DependentUpon>
|
||||
<Compile Include="Views\WordPressView.xaml.cs">
|
||||
<DependentUpon>WordPressView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
@@ -100,6 +110,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\WebNavigationView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\ShellView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -108,7 +122,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\WpView.xaml">
|
||||
<Page Include="Views\WordPressView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
@@ -148,8 +162,9 @@
|
||||
<Name>LaDOSE.DTO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
<Resource Include="Resources\64x64.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -8,10 +8,10 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace LaDOSE.DesktopApp.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace LaDOSE.DesktopApp.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
@@ -19,51 +19,43 @@ namespace LaDOSE.DesktopApp.Properties
|
||||
// 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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
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()
|
||||
{
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LaDOSE.DesktopApp.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,17 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace LaDOSE.DesktopApp.Properties
|
||||
{
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.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
|
||||
{
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
BIN
LaDOSE.Src/LaDOSE.DesktopApp/Resources/64x64.png
Normal file
BIN
LaDOSE.Src/LaDOSE.DesktopApp/Resources/64x64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Configuration;
|
||||
using System.Windows;
|
||||
using LaDOSE.DTO;
|
||||
@@ -64,6 +65,31 @@ namespace LaDOSE.DesktopApp.Services
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private R Post<P,R>(string resource, P entity)
|
||||
{
|
||||
var json = new RestSharp.Serialization.Json.JsonSerializer();
|
||||
var jsonD = new RestSharp.Serialization.Json.JsonDeserializer();
|
||||
var request = new RestRequest();
|
||||
request.Method = Method.POST;
|
||||
request.Resource = resource;
|
||||
request.AddHeader("Accept", "application/json");
|
||||
request.AddHeader("Content-type", "application/json");
|
||||
request.Parameters.Clear();
|
||||
request.AddParameter("application/json; charset=utf-8", json.Serialize(entity), ParameterType.RequestBody);
|
||||
//request.AddObject(entity);
|
||||
var response = Client.Execute(request);
|
||||
//var content = response.Content; // raw content as string
|
||||
try
|
||||
{
|
||||
return jsonD.Deserialize<R>(response);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return default(R);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -77,11 +103,17 @@ namespace LaDOSE.DesktopApp.Services
|
||||
}
|
||||
|
||||
|
||||
public bool CreateChallonge(int gameId, int eventId)
|
||||
public string CreateChallonge(int gameId, int eventId)
|
||||
{
|
||||
var restRequest = new RestRequest($"/api/wordpress/CreateChallonge/{gameId}/{eventId}", Method.GET);
|
||||
var restResponse = Client.Get<bool>(restRequest);
|
||||
return restResponse.Data;
|
||||
var restResponse = Client.Get(restRequest);
|
||||
return restResponse.Content;
|
||||
}
|
||||
public string CreateChallonge2(int gameId, int eventId, List<WPUser> optionalPlayers)
|
||||
{
|
||||
|
||||
var restResponse = Post<List<WPUser>,string>($"/api/wordpress/CreateChallonge/{gameId}/{eventId}",optionalPlayers);
|
||||
return restResponse;
|
||||
}
|
||||
public bool RefreshDb()
|
||||
{
|
||||
|
||||
@@ -16,6 +16,13 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
{
|
||||
this.RestService = restService;
|
||||
this.Games=new List<Game>();
|
||||
|
||||
}
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
LoadGames();
|
||||
base.OnInitialize();
|
||||
}
|
||||
|
||||
public void LoadGames()
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
using Caliburn.Micro;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Caliburn.Micro;
|
||||
using LaDOSE.DesktopApp.Services;
|
||||
|
||||
namespace LaDOSE.DesktopApp.ViewModels
|
||||
{
|
||||
public class ShellViewModel : Conductor<IScreen>.Collection.AllActive
|
||||
{
|
||||
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
this.DisplayName = "LaDOSE";
|
||||
this.AppIcon = BitmapFrame.Create(Application.GetResourceStream(new Uri("/LaDOSE.DesktopApp;component/Resources/64x64.png",
|
||||
UriKind.RelativeOrAbsolute)).Stream);
|
||||
var wordPressViewModel = new WordPressViewModel(IoC.Get<RestService>());
|
||||
ActivateItem(wordPressViewModel);
|
||||
base.OnInitialize();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public BitmapFrame AppIcon { get; set; }
|
||||
|
||||
public void LoadEvent()
|
||||
{
|
||||
ActivateItem(new WordPressViewModel(IoC.Get<RestService>()));
|
||||
@@ -23,5 +33,9 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
ActivateItem(new GameViewModel(IoC.Get<RestService>()));
|
||||
}
|
||||
|
||||
public void OpenWeb()
|
||||
{
|
||||
ActivateItem(new WebNavigationViewModel("www.google.com"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Caliburn.Micro;
|
||||
|
||||
namespace LaDOSE.DesktopApp.ViewModels
|
||||
{
|
||||
public class WebNavigationViewModel : Screen
|
||||
{
|
||||
public WebNavigationViewModel(string uri)
|
||||
{
|
||||
Uri = uri;
|
||||
this.DisplayName = Uri;
|
||||
}
|
||||
|
||||
public string Uri { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,8 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
private Game _selectedGame;
|
||||
private ObservableCollection<WPUser> _players;
|
||||
private ObservableCollection<WPUser> _playersOptions;
|
||||
|
||||
private ObservableCollection<WPUser> _optionalPlayers;
|
||||
|
||||
private RestService RestService { get; set; }
|
||||
|
||||
public WordPressViewModel(RestService restService)
|
||||
@@ -30,6 +31,121 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
this.RestService = restService;
|
||||
Players = new ObservableCollection<WPUser>();
|
||||
PlayersOptions = new ObservableCollection<WPUser>();
|
||||
OptionalPlayers = new ObservableCollection<WPUser>();
|
||||
}
|
||||
|
||||
#region Auto Property
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
Task.Factory.StartNew(new Action(this.Load), TaskCreationOptions.LongRunning).ContinueWith(t => { },
|
||||
CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted,
|
||||
TaskScheduler.FromCurrentSynchronizationContext());
|
||||
}
|
||||
|
||||
public bool CanGenerate
|
||||
{
|
||||
get { return SelectedWpEvent != null && SelectedGame != null && Players?.Count() > 0; }
|
||||
}
|
||||
|
||||
public List<WPEvent> Events { get; set; }
|
||||
|
||||
public WPEvent SelectedWpEvent
|
||||
{
|
||||
get => _selectedWpEvent;
|
||||
set
|
||||
{
|
||||
_selectedWpEvent = value;
|
||||
SelectedGame = null;
|
||||
ParseGame(_selectedWpEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public Game SelectedGame
|
||||
{
|
||||
get => _selectedGame;
|
||||
set
|
||||
{
|
||||
_selectedGame = value;
|
||||
|
||||
Players.Clear();
|
||||
PlayersOptions.Clear();
|
||||
|
||||
Task.Factory.StartNew(LoadPlayers, TaskCreationOptions.LongRunning).ContinueWith(t => { },
|
||||
CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted,
|
||||
TaskScheduler.FromCurrentSynchronizationContext());
|
||||
NotifyOfPropertyChange(() => SelectedGame);
|
||||
NotifyOfPropertyChange(() => this.CanGenerate);
|
||||
NotifyOfPropertyChange(() => Players);
|
||||
NotifyOfPropertyChange(() => PlayersOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<WPUser> Players
|
||||
{
|
||||
get => _players;
|
||||
set
|
||||
{
|
||||
_players = value;
|
||||
NotifyOfPropertyChange(() => Players);
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<WPUser> PlayersOptions
|
||||
{
|
||||
get => _playersOptions;
|
||||
set
|
||||
{
|
||||
_playersOptions = value;
|
||||
NotifyOfPropertyChange(() => PlayersOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<WPUser> OptionalPlayers
|
||||
{
|
||||
get => _optionalPlayers;
|
||||
set
|
||||
{
|
||||
_optionalPlayers = value;
|
||||
NotifyOfPropertyChange(() => OptionalPlayers);
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<Game> GamesFound { get; set; }
|
||||
public List<Game> Games { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
|
||||
public void UpdateDb()
|
||||
{
|
||||
Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
|
||||
var tsk = Task.Factory.StartNew(new Action(()=>this.RestService.RefreshDb()));
|
||||
tsk.ContinueWith(t =>
|
||||
{
|
||||
MessageBox.Show(t.Exception.InnerException.Message);
|
||||
},
|
||||
CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted,
|
||||
TaskScheduler.FromCurrentSynchronizationContext());
|
||||
|
||||
MessageBox.Show("Database updated");
|
||||
|
||||
}
|
||||
|
||||
public void Generate()
|
||||
{
|
||||
List<WPUser> test = new List<WPUser>();
|
||||
test = OptionalPlayers.ToList();
|
||||
var messageBoxText = this.RestService.CreateChallonge2(SelectedGame.Id, SelectedWpEvent.Id, test);
|
||||
|
||||
if (messageBoxText != null && messageBoxText.Length > 0 && !messageBoxText.Contains("error"))
|
||||
{
|
||||
System.Diagnostics.Process.Start($"https://challonge.com/{messageBoxText}");
|
||||
}
|
||||
else
|
||||
MessageBox.Show("Didn't work :(");
|
||||
}
|
||||
|
||||
public void LoadEvents()
|
||||
@@ -45,86 +161,7 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
TaskScheduler.FromCurrentSynchronizationContext());
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
GamesFound = new ObservableCollection<Game>();
|
||||
this.Games = this.RestService.GetGames();
|
||||
this.Events = this.RestService.GetEvents();
|
||||
|
||||
NotifyOfPropertyChange("Events");
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
System.Windows.Input.Mouse.OverrideCursor = null);
|
||||
}
|
||||
|
||||
|
||||
public bool CanGenerate
|
||||
{
|
||||
get { return SelectedWpEvent != null && SelectedGame != null; }
|
||||
}
|
||||
|
||||
|
||||
public List<WPEvent> Events { get; set; }
|
||||
|
||||
public WPEvent SelectedWpEvent
|
||||
{
|
||||
get => _selectedWpEvent;
|
||||
set
|
||||
{
|
||||
_selectedWpEvent = value;
|
||||
SelectedGame = null;
|
||||
ParseGame(_selectedWpEvent);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Game SelectedGame
|
||||
{
|
||||
get => _selectedGame;
|
||||
set
|
||||
{
|
||||
_selectedGame = value;
|
||||
|
||||
Players.Clear();
|
||||
PlayersOptions.Clear();
|
||||
|
||||
Task.Factory.StartNew(LoadPlayers,TaskCreationOptions.LongRunning).ContinueWith(t =>
|
||||
{
|
||||
|
||||
},
|
||||
CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted,
|
||||
TaskScheduler.FromCurrentSynchronizationContext());
|
||||
NotifyOfPropertyChange(() => SelectedGame);
|
||||
NotifyOfPropertyChange(() => this.CanGenerate);
|
||||
NotifyOfPropertyChange(() => Players);
|
||||
NotifyOfPropertyChange(() => PlayersOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ObservableCollection<WPUser> Players
|
||||
{
|
||||
get => _players;
|
||||
set
|
||||
{
|
||||
_players = value;
|
||||
NotifyOfPropertyChange(()=>Players);
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<WPUser> PlayersOptions
|
||||
{
|
||||
get => _playersOptions;
|
||||
set
|
||||
{
|
||||
_playersOptions = value;
|
||||
NotifyOfPropertyChange(() => PlayersOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ObservableCollection<Game> GamesFound { get; set; }
|
||||
public List<Game> Games { get; set; }
|
||||
#endregion
|
||||
|
||||
private void ParseGame(WPEvent selectedWpEvent)
|
||||
{
|
||||
@@ -153,32 +190,58 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
|
||||
private void LoadPlayers()
|
||||
{
|
||||
|
||||
if (SelectedWpEvent != null)
|
||||
if (SelectedGame != null)
|
||||
{
|
||||
this.RestService.GetUsers(SelectedWpEvent.Id, SelectedGame.Id).ForEach((e) => this.Players.AddUI(e));
|
||||
this.RestService.GetUsersOptions(SelectedWpEvent.Id, SelectedGame.Id).ForEach((e) => this.PlayersOptions.AddUI(e));
|
||||
var findUser = FindUser(SelectedWpEvent.Id, SelectedGame);
|
||||
var findUser2 = FindUser(SelectedWpEvent.Id, SelectedGame,true);
|
||||
|
||||
findUser.ForEach((e) => this.Players.AddUI(e));
|
||||
findUser2.ForEach((e) => this.PlayersOptions.AddUI(e));
|
||||
//this.RestService.GetUsers(SelectedWpEvent.Id, SelectedGame.Id)
|
||||
// .ForEach((e) => this.Players.AddUI(e));
|
||||
//this.RestService.GetUsersOptions(SelectedWpEvent.Id, SelectedGame.Id)
|
||||
// .ForEach((e) => this.PlayersOptions.AddUI(e));
|
||||
NotifyOfPropertyChange(() => this.CanGenerate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void UpdateDb()
|
||||
private void Load()
|
||||
{
|
||||
if (this.RestService.RefreshDb())
|
||||
MessageBox.Show("DataBaseUpdated");
|
||||
else
|
||||
MessageBox.Show("Update Failed");
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
System.Windows.Input.Mouse.OverrideCursor = Cursors.Wait);
|
||||
GamesFound = new ObservableCollection<Game>();
|
||||
this.Games = this.RestService.GetGames();
|
||||
this.Events = this.RestService.GetEvents();
|
||||
|
||||
NotifyOfPropertyChange("Events");
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
System.Windows.Input.Mouse.OverrideCursor = null);
|
||||
}
|
||||
|
||||
public void Generate()
|
||||
public List<WPUser> FindUser(int wpEventId, Game game,bool optional = false)
|
||||
{
|
||||
if (this.RestService.CreateChallonge(SelectedGame.Id, SelectedWpEvent.Id))
|
||||
MessageBox.Show("Challonge Created");
|
||||
else
|
||||
MessageBox.Show("Didn't worl :(");
|
||||
}
|
||||
|
||||
string[] selectedGameWpId;
|
||||
selectedGameWpId = !optional ? game.WordPressTag.Split(';') : game.WordPressTagOs.Split(';');
|
||||
|
||||
var currentWpEvent = this.Events.Where(e => e.Id == wpEventId).ToList();
|
||||
List<WPBooking> bookings = currentWpEvent.SelectMany(e => e.WpBookings).ToList();
|
||||
List<WPUser> users = new List<WPUser>();
|
||||
foreach (var booking in bookings)
|
||||
{
|
||||
var reservations = WpEventDeserialize.Parse(booking.Meta);
|
||||
if (reservations != null)
|
||||
{
|
||||
var gamesReservation = reservations.Where(e => e.Valid).Select(e => e.Name);
|
||||
if (selectedGameWpId.Any(e => gamesReservation.Contains(e)))
|
||||
{
|
||||
users.Add(booking.WpUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return users;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,16 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:LaDOSE.DesktopApp.Views"
|
||||
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
Icon="{Binding Path=AppIcon}"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Window.Resources>
|
||||
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Row="4" Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
@@ -32,10 +38,18 @@
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Web">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<cal:ActionMessage MethodName="OpenWeb">
|
||||
</cal:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Close" />
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
|
||||
<TabControl Grid.Row="1" x:Name="Items">
|
||||
<TabControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
17
LaDOSE.Src/LaDOSE.DesktopApp/Views/WebNavigationView.xaml
Normal file
17
LaDOSE.Src/LaDOSE.DesktopApp/Views/WebNavigationView.xaml
Normal file
@@ -0,0 +1,17 @@
|
||||
<UserControl x:Class="LaDOSE.DesktopApp.Views.WebNavigationView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:LaDOSE.DesktopApp.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid Row="4" Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
34
LaDOSE.Src/LaDOSE.DesktopApp/Views/WebNavigationView.xaml.cs
Normal file
34
LaDOSE.Src/LaDOSE.DesktopApp/Views/WebNavigationView.xaml.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
using LaDOSE.DesktopApp.ViewModels;
|
||||
|
||||
namespace LaDOSE.DesktopApp.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ShellView.xaml
|
||||
/// </summary>
|
||||
public partial class WebNavigationView : UserControl
|
||||
{
|
||||
public WebNavigationView()
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
29
LaDOSE.Src/LaDOSE.DesktopApp/Views/WebView.xaml.cs
Normal file
29
LaDOSE.Src/LaDOSE.DesktopApp/Views/WebView.xaml.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ShellView.xaml
|
||||
/// </summary>
|
||||
public partial class WebNavigationView : UserControl
|
||||
{
|
||||
public WebNavigationView()
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,16 @@
|
||||
xmlns:local="clr-namespace:LaDOSE.DesktopApp.Views"
|
||||
xmlns:userControls="clr-namespace:LaDOSE.DesktopApp.UserControls"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:behaviors="clr-namespace:LaDOSE.DesktopApp.Behaviors"
|
||||
mc:Ignorable="d"
|
||||
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid Row="4" Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="2*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -43,7 +46,7 @@
|
||||
<ColumnDefinition Width="2*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListView Grid.Column="0" ItemsSource="{Binding ElementName=EventsList,Path=SelectedItem.WpBookings}"
|
||||
x:Name="BookingList">
|
||||
x:Name="BookingList" IsTextSearchEnabled="True" TextSearch.TextPath="WpUser.Name">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@@ -76,7 +79,7 @@
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" cal:Message.Attach="Generate">Generate</Button>
|
||||
<ListView Grid.Row="1" x:Name="GameFoundListView" ItemsSource="{Binding GamesFound}"
|
||||
SelectedItem="{Binding SelectedGame,UpdateSourceTrigger=PropertyChanged}">
|
||||
SelectedItem="{Binding SelectedGame,UpdateSourceTrigger=PropertyChanged}" IsTextSearchEnabled="True" TextSearch.TextPath="Name">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@@ -99,7 +102,7 @@
|
||||
<Label Content="{Binding Players.Count,UpdateSourceTrigger=PropertyChanged}"></Label>
|
||||
<Label>)</Label>
|
||||
</StackPanel>
|
||||
<ListView Grid.Row="1" Grid.Column="0" x:Name="PlayersList" ItemsSource="{Binding Players,UpdateSourceTrigger=PropertyChanged}">
|
||||
<ListView Grid.Row="1" Grid.Column="0" x:Name="PlayersList" ItemsSource="{Binding Players,UpdateSourceTrigger=PropertyChanged}" IsTextSearchEnabled="True" TextSearch.TextPath="Name">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@@ -113,7 +116,8 @@
|
||||
<Label Content="{Binding PlayersOptions.Count,UpdateSourceTrigger=PropertyChanged}"></Label>
|
||||
<Label>)</Label>
|
||||
</StackPanel>
|
||||
<ListView Grid.Row="1" Grid.Column="1" x:Name="PlayersOptionsList" ItemsSource="{Binding PlayersOptions,UpdateSourceTrigger=PropertyChanged}">
|
||||
<ListView Grid.Row="1" Grid.Column="1" x:Name="PlayersOptionsList" ItemsSource="{Binding PlayersOptions,UpdateSourceTrigger=PropertyChanged}" IsTextSearchEnabled="True" TextSearch.TextPath="Name" behaviors:MultiSelectorBehaviours.SynchronizedSelectedItems="{Binding OptionalPlayers}">
|
||||
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@@ -22,6 +22,7 @@ namespace LaDOSE.DesktopApp.Views
|
||||
{
|
||||
public WordPressView()
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ namespace LaDOSE.Business.Interface
|
||||
List<WPUser> GetBooking(int wpEventId, Game game);
|
||||
List<WPUser> GetBookingOptions(int wpEventId, Game game);
|
||||
bool UpdateBooking();
|
||||
bool CreateChallonge(int gameId, int wpEventId);
|
||||
string CreateChallonge(int gameId, int wpEventId, IList<WPUser> additionPlayers);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ using LaDOSE.Entity.Context;
|
||||
using LaDOSE.Entity.Wordpress;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace LaDOSE.Business.Service
|
||||
{
|
||||
@@ -78,14 +79,14 @@ namespace LaDOSE.Business.Service
|
||||
}
|
||||
return users;
|
||||
}
|
||||
public bool CreateChallonge(int gameId, int wpEventId)
|
||||
public string CreateChallonge(int gameId, int wpEventId, IList<WPUser> additionalPlayers)
|
||||
{
|
||||
var selectedGame = _context.Game.FirstOrDefault(e => e.Id == gameId);
|
||||
var selectedGameWpId = selectedGame.WordPressTag.Split(';');
|
||||
var currentWpEvent = _context.WPEvent.Include(e => e.WPBookings).ThenInclude(e => e.WPUser)
|
||||
.Where(e => e.Id == wpEventId);
|
||||
var users = currentWpEvent.SelectMany(e => e.WPBookings.Select(u => u.WPUser));
|
||||
|
||||
var useradded = new List<WPUser>();
|
||||
|
||||
|
||||
if (selectedGame != null)
|
||||
@@ -110,6 +111,7 @@ namespace LaDOSE.Business.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
useradded.Add(booking.WPUser);
|
||||
_challongeProvider.AddPlayer(tournament.id, booking.WPUser.Name);
|
||||
}
|
||||
catch
|
||||
@@ -124,13 +126,25 @@ namespace LaDOSE.Business.Service
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
if (additionalPlayers != null && additionalPlayers.Count > 0)
|
||||
{
|
||||
foreach (var additionalPlayer in additionalPlayers)
|
||||
{
|
||||
if (useradded.All(e => e.Name != additionalPlayer.Name))
|
||||
{
|
||||
_challongeProvider.AddPlayer(tournament.id, additionalPlayer.Name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return tournament.url;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
return "error while creating challonge";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user