diff --git a/LanAdept/LanAdept.csproj b/LanAdept/LanAdept.csproj index f4efbf0..ef3ac06 100644 --- a/LanAdept/LanAdept.csproj +++ b/LanAdept/LanAdept.csproj @@ -202,6 +202,8 @@ + + @@ -354,6 +356,7 @@ + diff --git a/LanAdept/Views/Shared/_Layout.cshtml b/LanAdept/Views/Shared/_Layout.cshtml index 6d60b88..1b5e6a9 100644 --- a/LanAdept/Views/Shared/_Layout.cshtml +++ b/LanAdept/Views/Shared/_Layout.cshtml @@ -58,27 +58,49 @@ @Html.ListItemAction("Connexion", "Login", "Auth", new { ReturnUrl = Request.Url.AbsolutePath }) @Html.ListItemAction("Inscription", "Register", "Auth") - @if (LanAdeptCore.Service.UserService.IsTeamLeader()) + @if (LanAdeptCore.Service.UserService.IsUserLoggedIn()) { - int nbDemandes = @LanAdeptCore.Service.UserService.GetNbTeamDemand(); + + + + @if (LanAdeptCore.Service.UserService.IsTeamLeader() && LanAdeptCore.Service.UserService.GetNbTeamDemand() > 0) + { + @LanAdeptCore.Service.UserService.GetNbTeamDemand() + } + + + @Html.ListItemAction("Mon profil", "Index", "User") + @if (LanAdeptCore.Service.UserService.IsTeamLeader()) + { + int nbDemandes = @LanAdeptCore.Service.UserService.GetNbTeamDemand(); + + + + @if (LanAdeptCore.Service.UserService.GetNbTeams() > 1) + { + Mes équipes + } + else if (LanAdeptCore.Service.UserService.GetNbTeams() == 1) + { + Mon équipe + } + @if (nbDemandes > 0) + { + @nbDemandes + } + + + @*@Html.ListItemAction("Mes équipes", "Index", "Team", null, new { @class = "hidden-sm" })*@ + } - - - Mes équipes - @if (nbDemandes > 0) + @if (LanAdeptCore.Service.ReservationService.HasUserPlace()) { - @nbDemandes + @Html.ListItemAction("Ma place", "MaPlace", "Place") } - + @Html.ListItemAction("Déconnexion", "Logout", "Auth") + - @*@Html.ListItemAction("Mes équipes", "Index", "Team", null, new { @class = "hidden-sm" })*@ - } - - @if (LanAdeptCore.Service.ReservationService.HasUserPlace()) - { - @Html.ListItemAction("Ma place", "MaPlace", "Place") } - @Html.ListItemAction("Déconnexion", "Logout", "Auth") @@ -92,15 +114,15 @@ @Scripts.Render("~/bundles/jquery") diff --git a/LanAdept/Views/User/Index.cshtml b/LanAdept/Views/User/Index.cshtml new file mode 100644 index 0000000..d59aa62 --- /dev/null +++ b/LanAdept/Views/User/Index.cshtml @@ -0,0 +1,10 @@ +@model LanAdept.Views.User.ModelController.UserModel + +@{ + ViewBag.Title = "Index"; +} + +Mon profil + +@Html.DisplayFor(model => model.CompleteName) +@Html.DisplayFor(model => model.Email) diff --git a/LanAdept/Views/User/ModelController/UserController.cs b/LanAdept/Views/User/ModelController/UserController.cs new file mode 100644 index 0000000..cc752c6 --- /dev/null +++ b/LanAdept/Views/User/ModelController/UserController.cs @@ -0,0 +1,33 @@ +using LanAdept.Views.User.ModelController; +using LanAdeptCore.Service; +using LanAdeptData.DAL; +using LanAdeptData.Model.Users; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace LanAdept.Controllers +{ + public class UserController : Controller + { + private UnitOfWork uow + { + get { return UnitOfWork.Current; } + } + + [AllowAnonymous] + public ActionResult Index() + { + User u = UserService.GetLoggedInUser(); + + UserModel um = new UserModel(); + um.CompleteName = u.CompleteName; + um.Email = u.Email; + um.UserId = u.Id; + + return View(um); + } + } +} \ No newline at end of file diff --git a/LanAdept/Views/User/ModelController/UserModel.cs b/LanAdept/Views/User/ModelController/UserModel.cs new file mode 100644 index 0000000..472969a --- /dev/null +++ b/LanAdept/Views/User/ModelController/UserModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web; + +namespace LanAdept.Views.User.ModelController +{ + public class UserModel + { + public string UserId { get; set; } + [Required] + public string CompleteName { get; set; } + [Required] + public string Email { get; set; } + } +} \ No newline at end of file diff --git a/LanAdeptAdmin/Views/Tournaments/DetailsTeam.cshtml b/LanAdeptAdmin/Views/Tournaments/DetailsTeam.cshtml index 0e01e2c..ba4620e 100644 --- a/LanAdeptAdmin/Views/Tournaments/DetailsTeam.cshtml +++ b/LanAdeptAdmin/Views/Tournaments/DetailsTeam.cshtml @@ -89,6 +89,9 @@ @if (Model.TeamLeaderTag != gamerTag) { + + Promote + Exclure @@ -122,6 +125,24 @@ + + + + + × + Exclure un joueur + + + Voulez-vous vraiment promouvoir le joueur ""? + + + + + + @section Scripts { } \ No newline at end of file diff --git a/LanAdeptAdmin/Views/Tournaments/ModelController/TournamentController.cs b/LanAdeptAdmin/Views/Tournaments/ModelController/TournamentController.cs index 99b08ef..af54dff 100644 --- a/LanAdeptAdmin/Views/Tournaments/ModelController/TournamentController.cs +++ b/LanAdeptAdmin/Views/Tournaments/ModelController/TournamentController.cs @@ -12,6 +12,8 @@ using Microsoft.AspNet.Identity.Owin; using LanAdeptCore.Attribute.Authorization; using LanAdeptData.Model.Tournaments; +using LanAdeptData.Model.Users; +using LanAdeptCore.Service; namespace LanAdeptAdmin.Views { @@ -231,6 +233,30 @@ public ActionResult KickPlayer(int? gamerTagId, int? teamId) return RedirectToAction("DetailsTeam", new { id = teamId }); } + [LanAuthorize(Roles = "tournamentAdmin, tournamentMod")] + public ActionResult PromotePlayer(int? gamerTagId, int? teamId) + { + GamerTag gamerTag = uow.GamerTagRepository.GetByID(gamerTagId); + Team team = uow.TeamRepository.GetByID(teamId); + + if (team.TeamLeaderTag == gamerTag || team.GamerTags.Count == 1) + { + TempData["ErrorMessage"] = "Vous ne pouvez pas promouvoir le team leader."; + return RedirectToAction("DetailsTeam", new { id = teamId }); + } + else + { + + team.TeamLeaderTag = gamerTag; + + uow.TeamRepository.Update(team); + uow.GamerTagRepository.Update(gamerTag); + uow.Save(); + } + + return RedirectToAction("DetailsTeam", new { id = teamId }); + } + [LanAuthorize(Roles = "tournamentAdmin, tournamentMod")] public ActionResult EditTeam(int? teamId) { diff --git a/LanAdeptCore/Service/UserService.cs b/LanAdeptCore/Service/UserService.cs index a94af8b..c775bbb 100644 --- a/LanAdeptCore/Service/UserService.cs +++ b/LanAdeptCore/Service/UserService.cs @@ -73,5 +73,15 @@ public static int GetNbTeamDemand() return nbDemands; } + + public static int GetNbTeams() + { + if (!IsTeamLeader()) + return 0; + + IEnumerable teams = uow.TeamRepository.GetByTeamLeaderID(GetLoggedInUser().Id); + + return teams.Count(); + } } }
Voulez-vous vraiment promouvoir le joueur ""?