diff --git a/LanAdept/LanAdept.csproj b/LanAdept/LanAdept.csproj index ef3ac06..5d73db1 100644 --- a/LanAdept/LanAdept.csproj +++ b/LanAdept/LanAdept.csproj @@ -193,6 +193,7 @@ + @@ -357,6 +358,9 @@ + + + diff --git a/LanAdept/Views/Shared/_Layout.cshtml b/LanAdept/Views/Shared/_Layout.cshtml index 1b5e6a9..61c135e 100644 --- a/LanAdept/Views/Shared/_Layout.cshtml +++ b/LanAdept/Views/Shared/_Layout.cshtml @@ -1,5 +1,16 @@ @using LanAdeptCore.HtmlExtension; +@{ + bool isTeamLeader = LanAdeptCore.Service.UserService.IsTeamLeader(); + int nbDemandes = 0; + int nbTeams = 0; + if (isTeamLeader) + { + nbDemandes = LanAdeptCore.Service.UserService.GetNbTeamDemand(); + nbTeams = LanAdeptCore.Service.UserService.GetNbTeams(); + } +} + @@ -61,26 +72,34 @@ @if (LanAdeptCore.Service.UserService.IsUserLoggedIn()) { } diff --git a/LanAdept/Views/Team/Details.cshtml b/LanAdept/Views/Team/Details.cshtml index 5e2a1ef..bcda9cc 100644 --- a/LanAdept/Views/Team/Details.cshtml +++ b/LanAdept/Views/Team/Details.cshtml @@ -1,72 +1,49 @@ @using LanAdeptData.Model.Tournaments -@model LanAdept.Views.Teams.ModelController.DetailsModel +@using LanAdept.Views.Teams.ModelController +@using LanAdeptCore.Service +@model DetailsModel @{ - bool isConnected = LanAdeptCore.Service.UserService.IsUserLoggedIn(); - bool IsTeamLeader = LanAdeptCore.Service.UserService.IsTeamLeader(); + bool isConnected = UserService.IsUserLoggedIn(); + bool IsTeamLeader = UserService.IsTeamLeader(); ViewBag.Title = "Équipe " + Model.Name; } - - - - - - +@Html.Partial("ConfirmationModal", + new ModalModel() + { + Id = "promoteModal", + Title = "Promouvoir un joueur", + Body = "Voulez-vous vraiment promouvoir au rôle de team leader le joueur \" \"?", + BtnStyle = "success", + BtnText = "Promouvoir" + }) +@Html.Partial("ConfirmationModal", + new ModalModel() + { + Id = "kickModal", + Title = "Exclure un joueur", + Body = "Voulez-vous vraiment exclure le joueur \" \"?", + BtnStyle = "danger", + BtnText = "Exclure" + }) + +@Html.Partial("ConfirmationModal", + new ModalModel() + { + Id = "deleteModal", + Title = "Supprimer l'équipe", + Body = "Voulez-vous vraiment supprimer votre équipe \" \"?", + BtnStyle = "danger", + BtnText = "Supprimer" + }) @@ -187,5 +164,11 @@ modal.find('#modal-gamertag').text(gamertag); modal.find('#modal-link').attr("href", "@Url.Action("PromotePlayer", "Team", new { Id = Model.TeamID })" + "/?gamerTagId=" + gamertagId) }); + + $('#deleteModal').on('show.bs.modal', function (event) { + var modal = $(this); + modal.find('#modal-teamName').text("@Model.Name"); + modal.find('#modal-link').attr("href", "@Url.Action("Delete", new { Id = Model.TeamID })") + }); } \ No newline at end of file diff --git a/LanAdept/Views/Team/Index.cshtml b/LanAdept/Views/Team/Index.cshtml index ecde597..f36b6d8 100644 --- a/LanAdept/Views/Team/Index.cshtml +++ b/LanAdept/Views/Team/Index.cshtml @@ -29,10 +29,11 @@ { + [@Html.DisplayFor(model => team.Team.Tag)] @Html.DisplayFor(modelItem => team.Team.Name) - @team.Team.GamerTags.Count / @team.Team.Tournament.MaxPlayerPerTeam + @team.Team.GamerTags.Count / @Html.DisplayFor(model => team.Team.Tournament.MaxPlayerPerTeam) @if (team.Demandes == null) diff --git a/LanAdept/Views/Team/ModelController/ModalModel.cs b/LanAdept/Views/Team/ModelController/ModalModel.cs new file mode 100644 index 0000000..8d6ac41 --- /dev/null +++ b/LanAdept/Views/Team/ModelController/ModalModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace LanAdept.Views.Teams.ModelController +{ + public class ModalModel + { + public string Id { get; set; } + public string Title { get; set; } + public string Body { get; set; } + public string BtnStyle { get; set; } + public string BtnText { get; set; } + } +} \ No newline at end of file diff --git a/LanAdept/Views/Team/Partial/ConfirmationModal.cshtml b/LanAdept/Views/Team/Partial/ConfirmationModal.cshtml new file mode 100644 index 0000000..a1ea94b --- /dev/null +++ b/LanAdept/Views/Team/Partial/ConfirmationModal.cshtml @@ -0,0 +1,18 @@ +@model LanAdept.Views.Teams.ModelController.ModalModel + diff --git a/LanAdept/Views/Tournament/Details.cshtml b/LanAdept/Views/Tournament/Details.cshtml index 175c2e8..9737b47 100644 --- a/LanAdept/Views/Tournament/Details.cshtml +++ b/LanAdept/Views/Tournament/Details.cshtml @@ -1,4 +1,6 @@ -@model LanAdept.Views.Tournaments.ModelController.TournamentModel +@using LanAdept.Views.Tournaments.ModelController +@using LanAdeptData.Model.Tournaments +@model TournamentModel @{ ViewBag.Title = "Tournoi de " + Model.Game; @@ -43,16 +45,15 @@ else if (Model.IsStarted) @if (Model.Info != null) {

Informations et règlements

-
- @Html.Markdown(Model.Info) -
-
+
+ @Html.Markdown(Model.Info) +
+

Équipes

} @if (Model.Teams.Count() > 0) { - using (Html.BeginForm("JoinTeam", "Tournament", new LanAdept.Views.Tournaments.ModelController.JoinTeamModel() { TournamentID = Model.TournamentID })) { @Html.Hidden("GamerTagID", 0, new { id = "tagInput" }) @@ -68,35 +69,34 @@ else if (Model.IsStarted) - - + + - @foreach (LanAdept.Views.Tournaments.ModelController.TeamModel team in Model.Teams) - { - string hash = team.GetSeeTeamOnMapHash(); - + @foreach (TeamModel team in Model.Teams) + { + string hash = team.GetSeeTeamOnMapHash(); - @foreach (LanAdeptData.Model.Tournaments.Team team in Model.Teams) + @foreach (Team team in Model.Teams) {
ÉquipesMembres@Html.DisplayNameFor(model => model.Teams)@Html.DisplayNameFor(model => model.GamerTags) Nombre de joueur
@if (!string.IsNullOrWhiteSpace(team.Tag)) { - [@team.Tag.ToUpper()] + [@Html.DisplayFor(model => team.Tag)] } - @team.Name + @Html.DisplayFor(model => team.Name) - @foreach (LanAdeptData.Model.Tournaments.GamerTag gamerTag in team.Gamertags) + @foreach (GamerTag gamerTag in team.Gamertags) {
@if (gamerTag == team.TeamLeaderTag) { - @gamerTag.Gamertag + @Html.DisplayFor(model => gamerTag.Gamertag) } else { - @gamerTag.Gamertag + @Html.DisplayFor(model => gamerTag.Gamertag) }
} @@ -105,12 +105,12 @@ else if (Model.IsStarted) @if (team.Gamertags.Count() == Model.MaxPlayerPerTeam) { - @team.Gamertags.Count() / @Model.MaxPlayerPerTeam + @team.Gamertags.Count() / @Html.DisplayFor(model => model.MaxPlayerPerTeam) } else { - @team.Gamertags.Count() / @Model.MaxPlayerPerTeam + @team.Gamertags.Count() / @Html.DisplayFor(model => model.MaxPlayerPerTeam) }
@@ -164,7 +164,7 @@ else @Html.ActionLink("Soyez la première!", "AddTeam", new { id = Model.TournamentID }) }

-
+
} @Html.TextIconActionLink("Retour", "glyphicon-arrow-left", "Index", null, null, new { @class = "btn btn-default" }) diff --git a/LanAdept/Views/Tournament/ModelController/TeamModel.cs b/LanAdept/Views/Tournament/ModelController/TeamModel.cs index 4c7abf3..5c116ca 100644 --- a/LanAdept/Views/Tournament/ModelController/TeamModel.cs +++ b/LanAdept/Views/Tournament/ModelController/TeamModel.cs @@ -27,7 +27,7 @@ public class TeamModel public IEnumerable Gamertags { get; set; } - public TeamModel(Team team) + public TeamModel(LanAdeptData.Model.Tournaments.Team team) { TeamID = team.TeamID; Name = team.Name; diff --git a/LanAdept/Views/Tournament/ModelController/TournamentModel.cs b/LanAdept/Views/Tournament/ModelController/TournamentModel.cs index c66e36c..6faa7f2 100644 --- a/LanAdept/Views/Tournament/ModelController/TournamentModel.cs +++ b/LanAdept/Views/Tournament/ModelController/TournamentModel.cs @@ -20,9 +20,11 @@ public class TournamentModel [Display(Name = "Jeu")] public string Game { get; set; } - public IEnumerable Teams { get; set; } + [Display(Name = "Équipes")] + public IEnumerable Teams { get; set; } - public IEnumerable GamerTags { get; set; } + [Display(Name = "Membres")] + public IEnumerable GamerTags { get; set; } public bool IsConnected { get; set; } @@ -38,7 +40,7 @@ public class TournamentModel public bool CanAddTeam { get; set; } - public Team UserTeam { get; set; } + public LanAdeptData.Model.Tournaments.Team UserTeam { get; set; } public TournamentModel(Tournament tournament) { diff --git a/LanAdept/Views/User/Details.cshtml b/LanAdept/Views/User/Details.cshtml new file mode 100644 index 0000000..7886413 --- /dev/null +++ b/LanAdept/Views/User/Details.cshtml @@ -0,0 +1,33 @@ +@model LanAdeptData.Model.Users.User + +@{ + ViewBag.Title = "Details"; +} + +

Details

+ +
+

User

+
+
+
+ @Html.DisplayNameFor(model => model.CompleteName) +
+ +
+ @Html.DisplayFor(model => model.CompleteName) +
+ +
+ @Html.DisplayNameFor(model => model.Email) +
+ +
+ @Html.DisplayFor(model => model.Email) +
+
+
+
+ @Html.TextIconActionLink("Modifier", "glyphicon-pencil", "Edit", null, new { id = Model.Id }, new { @class = "btn btn-primary btn-mobile-full" }) + @Html.ActionLink("Back to List", "Index") +
diff --git a/LanAdept/Views/User/Edit.cshtml b/LanAdept/Views/User/Edit.cshtml new file mode 100644 index 0000000..c67e6cf --- /dev/null +++ b/LanAdept/Views/User/Edit.cshtml @@ -0,0 +1,45 @@ +@model LanAdept.Views.User.ModelController.UserModel + +@{ + ViewBag.Title = "Edit"; +} + +

Edit

+ +@using (Html.BeginForm()) +{ + @Html.AntiForgeryToken() + +
+

User

+
+ @Html.ValidationSummary(true, "", new { @class = "text-danger" }) + @Html.HiddenFor(model => model.UserId) + +
+ @Html.LabelFor(model => model.CompleteName, htmlAttributes: new { @class = "control-label col-md-2" }) +
+ @Html.EditorFor(model => model.CompleteName, new { htmlAttributes = new { @class = "form-control" } }) + @Html.ValidationMessageFor(model => model.CompleteName, "", new { @class = "text-danger" }) +
+
+ +
+ @Html.LabelFor(model => model.Email, htmlAttributes: new { @class = "control-label col-md-2" }) +
+ @Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" } }) + @Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger" }) +
+
+ +
+
+ +
+
+
+} + +
+ @Html.ActionLink("Back to List", "Index") +
diff --git a/LanAdept/Views/User/Index.cshtml b/LanAdept/Views/User/Index.cshtml index d59aa62..cf1ad19 100644 --- a/LanAdept/Views/User/Index.cshtml +++ b/LanAdept/Views/User/Index.cshtml @@ -1,10 +1,30 @@ @model LanAdept.Views.User.ModelController.UserModel @{ - ViewBag.Title = "Index"; + ViewBag.Title = "Index"; } -

Mon profil

+
+

Mon profil

+
+
+
+ @Html.DisplayNameFor(model => model.CompleteName) +
-@Html.DisplayFor(model => model.CompleteName) -@Html.DisplayFor(model => model.Email) +
+ @Html.DisplayFor(model => model.CompleteName) +
+ +
+ @Html.DisplayNameFor(model => model.Email) +
+ +
+ @Html.DisplayFor(model => model.Email) +
+
+
+ @Html.TextIconActionLink("Modifier", "glyphicon-pencil", "Edit", null, new { id = Model.UserId }, new { @class = "btn btn-primary btn-mobile-full" }) +
+
diff --git a/LanAdept/Views/User/ModelController/UserController.cs b/LanAdept/Views/User/ModelController/UserController.cs index cc752c6..2201ab5 100644 --- a/LanAdept/Views/User/ModelController/UserController.cs +++ b/LanAdept/Views/User/ModelController/UserController.cs @@ -1,4 +1,5 @@ using LanAdept.Views.User.ModelController; +using LanAdeptCore.Attribute.Authorization; using LanAdeptCore.Service; using LanAdeptData.DAL; using LanAdeptData.Model.Users; @@ -17,7 +18,7 @@ private UnitOfWork uow get { return UnitOfWork.Current; } } - [AllowAnonymous] + [LanAuthorize] public ActionResult Index() { User u = UserService.GetLoggedInUser(); @@ -29,5 +30,38 @@ public ActionResult Index() return View(um); } + + [LanAuthorize] + public ActionResult Edit() + { + User u = UserService.GetLoggedInUser(); + + UserModel um = new UserModel(); + um.CompleteName = u.CompleteName; + um.Email = u.Email; + um.UserId = u.Id; + + return View(um); + } + + [LanAuthorize] + [HttpPost] + public ActionResult Edit(UserModel um) + { + if (ModelState.IsValid) + { + User u = uow.UserRepository.GetByID(um.UserId); + u.CompleteName = um.CompleteName; + u.Email = um.Email; + u.UserName = um.Email; + + uow.UserRepository.Update(u); + uow.Save(); + return RedirectToAction("Index"); + } + return View(); + } + + } } \ No newline at end of file diff --git a/LanAdept/Views/User/ModelController/UserModel.cs b/LanAdept/Views/User/ModelController/UserModel.cs index 472969a..cf1477a 100644 --- a/LanAdept/Views/User/ModelController/UserModel.cs +++ b/LanAdept/Views/User/ModelController/UserModel.cs @@ -10,8 +10,11 @@ public class UserModel { public string UserId { get; set; } [Required] + [Display(Name = "Nom complet")] public string CompleteName { get; set; } [Required] + [Display(Name = "Email")] + [LanAdeptData.Validation.UniqueEmail] public string Email { get; set; } } } \ No newline at end of file diff --git a/LanAdeptAdmin/LanAdeptAdmin.csproj b/LanAdeptAdmin/LanAdeptAdmin.csproj index 618d55b..8a6bb7f 100644 --- a/LanAdeptAdmin/LanAdeptAdmin.csproj +++ b/LanAdeptAdmin/LanAdeptAdmin.csproj @@ -199,6 +199,7 @@ + @@ -353,6 +354,7 @@ + diff --git a/LanAdeptAdmin/Views/Tournaments/Details.cshtml b/LanAdeptAdmin/Views/Tournaments/Details.cshtml index a9b12cd..19fced0 100644 --- a/LanAdeptAdmin/Views/Tournaments/Details.cshtml +++ b/LanAdeptAdmin/Views/Tournaments/Details.cshtml @@ -1,4 +1,5 @@ -@model LanAdeptAdmin.Views.Tournaments.ModelController.TournamentModel +@using LanAdeptData.Model.Tournaments +@model LanAdeptAdmin.Views.Tournaments.ModelController.TournamentModel @{ ViewBag.Title = "Details"; @@ -90,7 +91,7 @@
diff --git a/LanAdeptAdmin/Views/Tournaments/DetailsTeam.cshtml b/LanAdeptAdmin/Views/Tournaments/DetailsTeam.cshtml index ba4620e..850c201 100644 --- a/LanAdeptAdmin/Views/Tournaments/DetailsTeam.cshtml +++ b/LanAdeptAdmin/Views/Tournaments/DetailsTeam.cshtml @@ -1,12 +1,11 @@ -@model LanAdeptAdmin.Views.Tournaments.ModelController.TeamModel +@using LanAdeptAdmin.Views.Tournaments.ModelController +@model TeamModel @{ ViewBag.Title = Model.Name; ViewBag.Sidebar = "_Sidebar_Tournament"; } - - @if (TempData["ErrorMessage"] != null) {
- Nom complet + @Html.DisplayNameFor(model => model.TeamGamerTags.First().User.CompleteName) @Html.DisplayNameFor(model => model.TeamGamerTags.First().Gamertag) @@ -77,22 +77,22 @@ {
- @gamerTag.User.CompleteName.ToString() + @Html.DisplayFor(model => gamerTag.User.CompleteName) @if (Model.TeamLeaderTag == gamerTag) { } - @gamerTag.Gamertag + @Html.DisplayFor(model => gamerTag.Gamertag) @if (Model.TeamLeaderTag != gamerTag) { - - } @@ -107,41 +107,24 @@ @Html.TextIconActionLink("Retour", "glyphicon-arrow-left", "Details", "Tournaments", new { id = Model.TournamentID }, new { @class = "btn btn-default" })

- - - +@Html.Partial("ConfirmationModal", + new ModalModel() + { + Id = "promoteModal", + Title = "Promouvoir un joueur", + Body = "Voulez-vous vraiment promouvoir au rôle de team leader le joueur \" \"?", + BtnStyle = "success", + BtnText = "Promouvoir" + }) +@Html.Partial("ConfirmationModal", + new ModalModel() + { + Id = "kickModal", + Title = "Exclure un joueur", + Body = "Voulez-vous vraiment exclure le joueur \" \"?", + BtnStyle = "danger", + BtnText = "Exclure" + }) @section Scripts {