Modification Zarghatt
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LaDOSE.Business.Interface;
|
using LaDOSE.Business.Interface;
|
||||||
using LaDOSE.Entity;
|
using LaDOSE.Entity;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace LaDOSE.Api.Controllers
|
namespace LaDOSE.Api.Controllers
|
||||||
@@ -35,5 +37,20 @@ namespace LaDOSE.Api.Controllers
|
|||||||
return _service.GetById(id);
|
return _service.GetById(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("{id}/delete")]
|
||||||
|
public IActionResult Delete(int id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _service.Delete((int) id) ? (IActionResult) NoContent() : NotFound();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LaDOSE.Business.Interface;
|
using LaDOSE.Business.Interface;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -33,5 +34,17 @@ namespace LaDOSE.Api.Controllers
|
|||||||
return AutoMapper.Mapper.Map<D>(_service.GetById(id));
|
return AutoMapper.Mapper.Map<D>(_service.GetById(id));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public IActionResult Delete(int id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _service.Delete((int)id) ? (IActionResult)NoContent() : NotFound();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return BadRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,24 +68,24 @@ namespace LaDOSE.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//[AllowAnonymous]
|
//[AllowAnonymous]
|
||||||
//[HttpPost("register")]
|
[HttpPost("register")]
|
||||||
//public IActionResult Register([FromBody]ApplicationUser userDto)
|
public IActionResult Register([FromBody]ApplicationUser userDto)
|
||||||
//{
|
{
|
||||||
// // map dto to entity
|
// map dto to entity
|
||||||
|
|
||||||
|
|
||||||
// try
|
|
||||||
// {
|
try
|
||||||
// // save
|
{
|
||||||
// _userService.Create(userDto, userDto.Password);
|
// save
|
||||||
// return Ok();
|
_userService.Create(userDto, userDto.Password);
|
||||||
// }
|
return Ok();
|
||||||
// catch (Exception ex)
|
}
|
||||||
// {
|
catch (Exception ex)
|
||||||
// // return error message if there was an exception
|
{
|
||||||
// return BadRequest(new { message = ex.Message });
|
// return error message if there was an exception
|
||||||
// }
|
return BadRequest(new { message = ex.Message });
|
||||||
//}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,9 +149,15 @@ namespace LaDOSE.DesktopApp.Services
|
|||||||
return restResponse.Data;
|
return restResponse.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameDTO UpdateGame(GameDTO eventUpdate)
|
public GameDTO UpdateGame(GameDTO game)
|
||||||
{
|
{
|
||||||
return Post("Api/Game", eventUpdate);
|
return Post("Api/Game", game);
|
||||||
|
}
|
||||||
|
public bool DeleteGame(int gameId)
|
||||||
|
{
|
||||||
|
var restRequest = new RestRequest($"/api/Game/{gameId}", Method.DELETE);
|
||||||
|
var restResponse = Client.Execute(restRequest);
|
||||||
|
return restResponse.IsSuccessful;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace LaDOSE.DesktopApp.ViewModels
|
|||||||
{
|
{
|
||||||
_currentGame = value;
|
_currentGame = value;
|
||||||
NotifyOfPropertyChange(()=>CurrentGame);
|
NotifyOfPropertyChange(()=>CurrentGame);
|
||||||
|
NotifyOfPropertyChange(() => CanDeleteGame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +61,16 @@ namespace LaDOSE.DesktopApp.ViewModels
|
|||||||
public void AddGame()
|
public void AddGame()
|
||||||
{
|
{
|
||||||
var item = new GameDTO();
|
var item = new GameDTO();
|
||||||
this.Games.Add(item);
|
this.RestService.UpdateGame(item);
|
||||||
this.CurrentGame = item;
|
LoadGames();
|
||||||
}
|
}
|
||||||
|
public void DeleteGame()
|
||||||
|
{
|
||||||
|
|
||||||
|
this.RestService.DeleteGame(this.CurrentGame.Id);
|
||||||
|
LoadGames();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanDeleteGame => CurrentGame != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -197,8 +197,8 @@ namespace LaDOSE.DesktopApp.ViewModels
|
|||||||
var findUser = FindUser(SelectedWpEvent.Id, SelectedGame);
|
var findUser = FindUser(SelectedWpEvent.Id, SelectedGame);
|
||||||
var findUser2 = FindUser(SelectedWpEvent.Id, SelectedGame,true);
|
var findUser2 = FindUser(SelectedWpEvent.Id, SelectedGame,true);
|
||||||
|
|
||||||
findUser.ForEach((e) => this.Players.AddUI(e,()=>NotifyOfPropertyChange(() => this.CanGenerate)));
|
findUser.OrderBy(e=>e.Name).ToList().ForEach((e) => this.Players.AddUI(e,()=>NotifyOfPropertyChange(() => this.CanGenerate)));
|
||||||
findUser2.ForEach((e) => this.PlayersOptions.AddUI(e,null));
|
findUser2.OrderBy(e => e.Name).ToList().ForEach((e) => this.PlayersOptions.AddUI(e,null));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,9 @@
|
|||||||
<RowDefinition Height="*"></RowDefinition>
|
<RowDefinition Height="*"></RowDefinition>
|
||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Button Grid.Row="0" Grid.ColumnSpan="2" x:Name="AddGame">Add Games</Button>
|
<Button Grid.Row="0" Grid.Column="0" x:Name="AddGame">Add Game</Button>
|
||||||
|
|
||||||
|
<Button Grid.Row="0" Grid.Column="1" x:Name="DeleteGame">Delete Game</Button>
|
||||||
<Label Grid.Row="1" Grid.Column="0">Id</Label>
|
<Label Grid.Row="1" Grid.Column="0">Id</Label>
|
||||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=CurrentGame.Id,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True"></TextBox>
|
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=CurrentGame.Id,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True"></TextBox>
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||||
<ColumnDefinition Width="2*"></ColumnDefinition>
|
<ColumnDefinition Width="2*"></ColumnDefinition>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<ListView Grid.Column="0" ItemsSource="{Binding ElementName=EventsList,Path=SelectedItem.WpBookings}"
|
<ListView Grid.Column="0" ItemsSource="{Binding ElementName=EventsList,Path=SelectedItem.WpBookings}"
|
||||||
x:Name="BookingList" IsTextSearchEnabled="True" TextSearch.TextPath="WpUser.Name" Margin="2" KeyUp="Copy">
|
x:Name="BookingList" IsTextSearchEnabled="True" TextSearch.TextPath="WpUser.Name" Margin="2" KeyUp="Copy">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace LaDOSE.Business.Service
|
|||||||
public virtual bool Update(T entity)
|
public virtual bool Update(T entity)
|
||||||
{
|
{
|
||||||
var entityEntry = _context.Update(entity);
|
var entityEntry = _context.Update(entity);
|
||||||
|
this._context.SaveChanges();
|
||||||
return _context.Entry(entityEntry).State == EntityState.Unchanged;
|
return _context.Entry(entityEntry).State == EntityState.Unchanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ namespace LaDOSE.Business.Service
|
|||||||
{
|
{
|
||||||
var find = _context.Find<T>(id);
|
var find = _context.Find<T>(id);
|
||||||
_context.Remove(find);
|
_context.Remove(find);
|
||||||
|
this._context.SaveChanges();
|
||||||
return _context.Entry(find).State == EntityState.Deleted;
|
return _context.Entry(find).State == EntityState.Deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user