Skip to content

Commit

Permalink
[#29] Oublie du delete pour un utilisateur
Browse files Browse the repository at this point in the history
  • Loading branch information
island212 committed Mar 9, 2016
1 parent 0b907e5 commit da62c85
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion LanAdept/Views/Team/ModelController/TeamController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
using Microsoft.AspNet.Identity.Owin;
using LanAdeptData.Model.Users;
using LanAdeptData.Model.Tournaments;
using LanAdeptCore.Service.Challonge.Response;
using LanAdeptCore.Service.Challonge;
using System.Threading.Tasks;

namespace LanAdept.Controllers
{
Expand Down Expand Up @@ -277,7 +280,7 @@ public ActionResult CancelDemande(int id)
}

[LanAuthorize]
public ActionResult Delete(int id)
public async Task<ActionResult> Delete(int id)
{
if (!UserService.IsTeamLeader())
return RedirectToAction("Index", "Home");
Expand All @@ -288,6 +291,16 @@ public ActionResult Delete(int id)
if (user.Id != team.TeamLeaderTag.UserID)
return RedirectToAction("Index", "Home");

if (team.Tournament.ChallongeUrl != null)
{
SimpleResponse response = await ChallongeService.DeleteParticipant(team.Tournament.ChallongeUrl, team.ChallongeID.Value);

if (response.HasError)
{
return RedirectToAction("Index", "Home");
}
}

List<Demande> demandes = uow.DemandeRepository.GetByTeamId(id);
foreach (Demande demande in demandes)
{
Expand Down

0 comments on commit da62c85

Please sign in to comment.