REST to a .Net Standard Library
Test REST in discord bot and WPF Small improvements
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Caliburn.Micro;
|
||||
using LaDOSE.DesktopApp.Services;
|
||||
using LaDOSE.DTO;
|
||||
using LaDOSE.REST;
|
||||
|
||||
namespace LaDOSE.DesktopApp.ViewModels
|
||||
{
|
||||
@@ -16,19 +17,20 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
{
|
||||
this.RestService = restService;
|
||||
this.Games=new List<GameDTO>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
LoadGames();
|
||||
this.CurrentGame = Games.First();
|
||||
base.OnInitialize();
|
||||
}
|
||||
|
||||
public void LoadGames()
|
||||
{
|
||||
this.Games.Clear();
|
||||
this.Games = this.RestService.GetGames();
|
||||
var gameDtos = this.RestService.GetGames().OrderBy(e=>e.Order).ToList();
|
||||
this.Games = gameDtos;
|
||||
NotifyOfPropertyChange("Games");
|
||||
}
|
||||
|
||||
@@ -56,7 +58,8 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
public void Update()
|
||||
{
|
||||
this.RestService.UpdateGame(this.CurrentGame);
|
||||
this.Games = RestService.GetGames();
|
||||
LoadGames();
|
||||
|
||||
}
|
||||
public void AddGame()
|
||||
{
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Caliburn.Micro;
|
||||
using LaDOSE.DesktopApp.Services;
|
||||
using LaDOSE.REST;
|
||||
|
||||
namespace LaDOSE.DesktopApp.ViewModels
|
||||
{
|
||||
@@ -15,6 +16,16 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
this.DisplayName = "LaDOSE";
|
||||
this.AppIcon = BitmapFrame.Create(Application.GetResourceStream(new Uri("/LaDOSE.DesktopApp;component/Resources/64x64.png",
|
||||
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>());
|
||||
ActivateItem(wordPressViewModel);
|
||||
base.OnInitialize();
|
||||
|
||||
@@ -8,9 +8,9 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Caliburn.Micro;
|
||||
using LaDOSE.DesktopApp.Services;
|
||||
using LaDOSE.DesktopApp.Utils;
|
||||
using LaDOSE.DTO;
|
||||
using LaDOSE.REST;
|
||||
using Action = System.Action;
|
||||
|
||||
namespace LaDOSE.DesktopApp.ViewModels
|
||||
@@ -169,7 +169,7 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
var reservation = SelectedWpEvent.WpBookings.FirstOrDefault();
|
||||
var games = WpEventDeserialize.Parse(reservation.Meta);
|
||||
GamesFound.Clear();
|
||||
|
||||
var foundGames = new List<GameDTO>();
|
||||
if (games != null)
|
||||
{
|
||||
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));
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -209,8 +215,9 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
System.Windows.Input.Mouse.OverrideCursor = Cursors.Wait);
|
||||
GamesFound = new ObservableCollection<GameDTO>();
|
||||
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");
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
System.Windows.Input.Mouse.OverrideCursor = null);
|
||||
|
||||
Reference in New Issue
Block a user