From 09481ff8f6d3e14080e347addb205bba5816e0c1 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Wed, 20 Sep 2017 14:28:48 +0200 Subject: [PATCH] Inscriptions: * traductions * Controlleur des utilisateurs --- Yavsc/Controllers/UsersController.cs | 127 +++++++++++++ Yavsc/Models/ApplicationDbContext.cs | 2 + ...ml => ExternalLoginConfirmation.en.cshtml} | 86 +++++---- .../ExternalLoginConfirmation.fr.cshtml | 42 +++++ Yavsc/Views/Users/Create.cshtml | 168 +++++++++++++++++ Yavsc/Views/Users/Delete.cshtml | 136 ++++++++++++++ Yavsc/Views/Users/Details.cshtml | 132 ++++++++++++++ Yavsc/Views/Users/Edit.cshtml | 170 ++++++++++++++++++ Yavsc/Views/Users/Index.cshtml | 140 +++++++++++++++ 9 files changed, 959 insertions(+), 44 deletions(-) create mode 100644 Yavsc/Controllers/UsersController.cs rename Yavsc/Views/Account/{ExternalLoginConfirmation.cshtml => ExternalLoginConfirmation.en.cshtml} (90%) create mode 100755 Yavsc/Views/Account/ExternalLoginConfirmation.fr.cshtml create mode 100644 Yavsc/Views/Users/Create.cshtml create mode 100644 Yavsc/Views/Users/Delete.cshtml create mode 100644 Yavsc/Views/Users/Details.cshtml create mode 100644 Yavsc/Views/Users/Edit.cshtml create mode 100644 Yavsc/Views/Users/Index.cshtml diff --git a/Yavsc/Controllers/UsersController.cs b/Yavsc/Controllers/UsersController.cs new file mode 100644 index 00000000..c6ad2aeb --- /dev/null +++ b/Yavsc/Controllers/UsersController.cs @@ -0,0 +1,127 @@ +using System.Threading.Tasks; +using Microsoft.AspNet.Authorization; +using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.Rendering; +using Microsoft.Data.Entity; +using Yavsc.Models; + +namespace Yavsc.Controllers +{ + [Authorize("AdministratorOnly")] + public class UsersController : Controller + { + private ApplicationDbContext _context; + + public UsersController(ApplicationDbContext context) + { + _context = context; + } + + // GET: Users + public async Task Index() + { + var applicationDbContext = _context.ApplicationUser.Include(a => a.PostalAddress); + return View(await applicationDbContext.ToListAsync()); + } + + // GET: Users/Details/5 + public async Task Details(string id) + { + if (id == null) + { + return HttpNotFound(); + } + + ApplicationUser applicationUser = await _context.ApplicationUser.SingleAsync(m => m.Id == id); + if (applicationUser == null) + { + return HttpNotFound(); + } + + return View(applicationUser); + } + + // GET: Users/Create + public IActionResult Create() + { + ViewData["PostalAddressId"] = new SelectList(_context.Map, "Id", "PostalAddress"); + return View(); + } + + // POST: Users/Create + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Create(ApplicationUser applicationUser) + { + if (ModelState.IsValid) + { + _context.ApplicationUser.Add(applicationUser); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + ViewData["PostalAddressId"] = new SelectList(_context.Map, "Id", "PostalAddress", applicationUser.PostalAddressId); + return View(applicationUser); + } + + // GET: Users/Edit/5 + public async Task Edit(string id) + { + if (id == null) + { + return HttpNotFound(); + } + + ApplicationUser applicationUser = await _context.ApplicationUser.SingleAsync(m => m.Id == id); + if (applicationUser == null) + { + return HttpNotFound(); + } + ViewData["PostalAddressId"] = new SelectList(_context.Map, "Id", "PostalAddress", applicationUser.PostalAddressId); + return View(applicationUser); + } + + // POST: Users/Edit/5 + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Edit(ApplicationUser applicationUser) + { + if (ModelState.IsValid) + { + _context.Update(applicationUser); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + ViewData["PostalAddressId"] = new SelectList(_context.Map, "Id", "PostalAddress", applicationUser.PostalAddressId); + return View(applicationUser); + } + + // GET: Users/Delete/5 + [ActionName("Delete")] + public async Task Delete(string id) + { + if (id == null) + { + return HttpNotFound(); + } + + ApplicationUser applicationUser = await _context.ApplicationUser.SingleAsync(m => m.Id == id); + if (applicationUser == null) + { + return HttpNotFound(); + } + + return View(applicationUser); + } + + // POST: Users/Delete/5 + [HttpPost, ActionName("Delete")] + [ValidateAntiForgeryToken] + public async Task DeleteConfirmed(string id) + { + ApplicationUser applicationUser = await _context.ApplicationUser.SingleAsync(m => m.Id == id); + _context.ApplicationUser.Remove(applicationUser); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + } +} diff --git a/Yavsc/Models/ApplicationDbContext.cs b/Yavsc/Models/ApplicationDbContext.cs index b24b2aff..d0432c45 100644 --- a/Yavsc/Models/ApplicationDbContext.cs +++ b/Yavsc/Models/ApplicationDbContext.cs @@ -280,5 +280,7 @@ namespace Yavsc.Models public DbSet Period { get; set; } public DbSet BlogTags { get; set; } + + public DbSet ApplicationUser { get; set; } } } diff --git a/Yavsc/Views/Account/ExternalLoginConfirmation.cshtml b/Yavsc/Views/Account/ExternalLoginConfirmation.en.cshtml similarity index 90% rename from Yavsc/Views/Account/ExternalLoginConfirmation.cshtml rename to Yavsc/Views/Account/ExternalLoginConfirmation.en.cshtml index 4754361e..3e8a8f26 100755 --- a/Yavsc/Views/Account/ExternalLoginConfirmation.cshtml +++ b/Yavsc/Views/Account/ExternalLoginConfirmation.en.cshtml @@ -1,44 +1,42 @@ -@model ExternalLoginConfirmationViewModel -@{ - ViewData["Title"] = "Register"; -} - -

@ViewData["Title"].

-

Associate your @ViewData["LoginProvider"] account.

- -@ViewData["jsonres"] - -
-

Association Form

-
-
- -

- You've successfully authenticated with @ViewData["LoginProvider"]. - Please enter a user name for this site below and click the Register button to finish - logging in. -

-
- -
- - -
-
-
- -
- - -
-
-
-
- -
-
-
- -@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } -} +@model ExternalLoginConfirmationViewModel +@{ + ViewData["Title"] = "Register"; +} + +

@ViewData["Title"].

+

Assoiciez votre compte @ViewData["LoginProvider"].

+ +
+

Formulaire d'Association

+
+
+ +

+ You've successfully authenticated with @ViewData["LoginProvider"]. + Please enter a user name for this site below and click the Register button to finish + logging in. +

+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } +} diff --git a/Yavsc/Views/Account/ExternalLoginConfirmation.fr.cshtml b/Yavsc/Views/Account/ExternalLoginConfirmation.fr.cshtml new file mode 100755 index 00000000..f1524845 --- /dev/null +++ b/Yavsc/Views/Account/ExternalLoginConfirmation.fr.cshtml @@ -0,0 +1,42 @@ +@model ExternalLoginConfirmationViewModel +@{ + ViewData["Title"] = "Register"; +} + +

@ViewData["Title"].

+

Assoiciez votre compte @ViewData["LoginProvider"].

+ +
+

Formulaire d'Association

+
+
+ +

+ Vous vous êtes authentifié avec succès auprès de @ViewData["LoginProvider"]. + Veuillez s'il vous plait, saisir un nom d'utilisateur ci-dessous + et activer le boutton "Enregister" pour terminer votre inscription. +

+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } +} diff --git a/Yavsc/Views/Users/Create.cshtml b/Yavsc/Views/Users/Create.cshtml new file mode 100644 index 00000000..ee7cae16 --- /dev/null +++ b/Yavsc/Views/Users/Create.cshtml @@ -0,0 +1,168 @@ +@model Yavsc.Models.ApplicationUser + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +
+
+

ApplicationUser

+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+ + + diff --git a/Yavsc/Views/Users/Delete.cshtml b/Yavsc/Views/Users/Delete.cshtml new file mode 100644 index 00000000..cab00fed --- /dev/null +++ b/Yavsc/Views/Users/Delete.cshtml @@ -0,0 +1,136 @@ +@model Yavsc.Models.ApplicationUser + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

ApplicationUser

+
+
+
+ @Html.DisplayNameFor(model => model.AccessFailedCount) +
+
+ @Html.DisplayFor(model => model.AccessFailedCount) +
+
+ @Html.DisplayNameFor(model => model.Avatar) +
+
+ @Html.DisplayFor(model => model.Avatar) +
+
+ @Html.DisplayNameFor(model => model.ConcurrencyStamp) +
+
+ @Html.DisplayFor(model => model.ConcurrencyStamp) +
+
+ @Html.DisplayNameFor(model => model.DedicatedGoogleCalendar) +
+
+ @Html.DisplayFor(model => model.DedicatedGoogleCalendar) +
+
+ @Html.DisplayNameFor(model => model.DiskQuota) +
+
+ @Html.DisplayFor(model => model.DiskQuota) +
+
+ @Html.DisplayNameFor(model => model.DiskUsage) +
+
+ @Html.DisplayFor(model => model.DiskUsage) +
+
+ @Html.DisplayNameFor(model => model.Email) +
+
+ @Html.DisplayFor(model => model.Email) +
+
+ @Html.DisplayNameFor(model => model.EmailConfirmed) +
+
+ @Html.DisplayFor(model => model.EmailConfirmed) +
+
+ @Html.DisplayNameFor(model => model.FullName) +
+
+ @Html.DisplayFor(model => model.FullName) +
+
+ @Html.DisplayNameFor(model => model.LockoutEnabled) +
+
+ @Html.DisplayFor(model => model.LockoutEnabled) +
+
+ @Html.DisplayNameFor(model => model.LockoutEnd) +
+
+ @Html.DisplayFor(model => model.LockoutEnd) +
+
+ @Html.DisplayNameFor(model => model.NormalizedEmail) +
+
+ @Html.DisplayFor(model => model.NormalizedEmail) +
+
+ @Html.DisplayNameFor(model => model.NormalizedUserName) +
+
+ @Html.DisplayFor(model => model.NormalizedUserName) +
+
+ @Html.DisplayNameFor(model => model.PasswordHash) +
+
+ @Html.DisplayFor(model => model.PasswordHash) +
+
+ @Html.DisplayNameFor(model => model.PhoneNumber) +
+
+ @Html.DisplayFor(model => model.PhoneNumber) +
+
+ @Html.DisplayNameFor(model => model.PhoneNumberConfirmed) +
+
+ @Html.DisplayFor(model => model.PhoneNumberConfirmed) +
+
+ @Html.DisplayNameFor(model => model.SecurityStamp) +
+
+ @Html.DisplayFor(model => model.SecurityStamp) +
+
+ @Html.DisplayNameFor(model => model.TwoFactorEnabled) +
+
+ @Html.DisplayFor(model => model.TwoFactorEnabled) +
+
+ @Html.DisplayNameFor(model => model.UserName) +
+
+ @Html.DisplayFor(model => model.UserName) +
+
+ +
+
+ | + Back to List +
+
+
diff --git a/Yavsc/Views/Users/Details.cshtml b/Yavsc/Views/Users/Details.cshtml new file mode 100644 index 00000000..dfdc5631 --- /dev/null +++ b/Yavsc/Views/Users/Details.cshtml @@ -0,0 +1,132 @@ +@model Yavsc.Models.ApplicationUser + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

ApplicationUser

+
+
+
+ @Html.DisplayNameFor(model => model.AccessFailedCount) +
+
+ @Html.DisplayFor(model => model.AccessFailedCount) +
+
+ @Html.DisplayNameFor(model => model.Avatar) +
+
+ @Html.DisplayFor(model => model.Avatar) +
+
+ @Html.DisplayNameFor(model => model.ConcurrencyStamp) +
+
+ @Html.DisplayFor(model => model.ConcurrencyStamp) +
+
+ @Html.DisplayNameFor(model => model.DedicatedGoogleCalendar) +
+
+ @Html.DisplayFor(model => model.DedicatedGoogleCalendar) +
+
+ @Html.DisplayNameFor(model => model.DiskQuota) +
+
+ @Html.DisplayFor(model => model.DiskQuota) +
+
+ @Html.DisplayNameFor(model => model.DiskUsage) +
+
+ @Html.DisplayFor(model => model.DiskUsage) +
+
+ @Html.DisplayNameFor(model => model.Email) +
+
+ @Html.DisplayFor(model => model.Email) +
+
+ @Html.DisplayNameFor(model => model.EmailConfirmed) +
+
+ @Html.DisplayFor(model => model.EmailConfirmed) +
+
+ @Html.DisplayNameFor(model => model.FullName) +
+
+ @Html.DisplayFor(model => model.FullName) +
+
+ @Html.DisplayNameFor(model => model.LockoutEnabled) +
+
+ @Html.DisplayFor(model => model.LockoutEnabled) +
+
+ @Html.DisplayNameFor(model => model.LockoutEnd) +
+
+ @Html.DisplayFor(model => model.LockoutEnd) +
+
+ @Html.DisplayNameFor(model => model.NormalizedEmail) +
+
+ @Html.DisplayFor(model => model.NormalizedEmail) +
+
+ @Html.DisplayNameFor(model => model.NormalizedUserName) +
+
+ @Html.DisplayFor(model => model.NormalizedUserName) +
+
+ @Html.DisplayNameFor(model => model.PasswordHash) +
+
+ @Html.DisplayFor(model => model.PasswordHash) +
+
+ @Html.DisplayNameFor(model => model.PhoneNumber) +
+
+ @Html.DisplayFor(model => model.PhoneNumber) +
+
+ @Html.DisplayNameFor(model => model.PhoneNumberConfirmed) +
+
+ @Html.DisplayFor(model => model.PhoneNumberConfirmed) +
+
+ @Html.DisplayNameFor(model => model.SecurityStamp) +
+
+ @Html.DisplayFor(model => model.SecurityStamp) +
+
+ @Html.DisplayNameFor(model => model.TwoFactorEnabled) +
+
+ @Html.DisplayFor(model => model.TwoFactorEnabled) +
+
+ @Html.DisplayNameFor(model => model.UserName) +
+
+ @Html.DisplayFor(model => model.UserName) +
+
+
+

+ Edit | + Back to List +

diff --git a/Yavsc/Views/Users/Edit.cshtml b/Yavsc/Views/Users/Edit.cshtml new file mode 100644 index 00000000..f61fd684 --- /dev/null +++ b/Yavsc/Views/Users/Edit.cshtml @@ -0,0 +1,170 @@ +@model Yavsc.Models.ApplicationUser + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +
+
+

ApplicationUser

+
+
+ +
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+ + + diff --git a/Yavsc/Views/Users/Index.cshtml b/Yavsc/Views/Users/Index.cshtml new file mode 100644 index 00000000..b9486c60 --- /dev/null +++ b/Yavsc/Views/Users/Index.cshtml @@ -0,0 +1,140 @@ +@model IEnumerable + +@{ + ViewData["Title"] = "Index"; +} + +

Index

+ +

+ Create New +

+ + + + + + + + + + + + + + + + + + + + + + + + +@foreach (var item in Model) { + + + + + + + + + + + + + + + + + + + + + + +} +
+ @Html.DisplayNameFor(model => model.AccessFailedCount) + + @Html.DisplayNameFor(model => model.Avatar) + + @Html.DisplayNameFor(model => model.ConcurrencyStamp) + + @Html.DisplayNameFor(model => model.DedicatedGoogleCalendar) + + @Html.DisplayNameFor(model => model.DiskQuota) + + @Html.DisplayNameFor(model => model.DiskUsage) + + @Html.DisplayNameFor(model => model.Email) + + @Html.DisplayNameFor(model => model.EmailConfirmed) + + @Html.DisplayNameFor(model => model.FullName) + + @Html.DisplayNameFor(model => model.LockoutEnabled) + + @Html.DisplayNameFor(model => model.LockoutEnd) + + @Html.DisplayNameFor(model => model.NormalizedEmail) + + @Html.DisplayNameFor(model => model.NormalizedUserName) + + @Html.DisplayNameFor(model => model.PasswordHash) + + @Html.DisplayNameFor(model => model.PhoneNumber) + + @Html.DisplayNameFor(model => model.PhoneNumberConfirmed) + + @Html.DisplayNameFor(model => model.SecurityStamp) + + @Html.DisplayNameFor(model => model.TwoFactorEnabled) + + @Html.DisplayNameFor(model => model.UserName) +
+ @Html.DisplayFor(modelItem => item.AccessFailedCount) + + @Html.DisplayFor(modelItem => item.Avatar) + + @Html.DisplayFor(modelItem => item.ConcurrencyStamp) + + @Html.DisplayFor(modelItem => item.DedicatedGoogleCalendar) + + @Html.DisplayFor(modelItem => item.DiskQuota) + + @Html.DisplayFor(modelItem => item.DiskUsage) + + @Html.DisplayFor(modelItem => item.Email) + + @Html.DisplayFor(modelItem => item.EmailConfirmed) + + @Html.DisplayFor(modelItem => item.FullName) + + @Html.DisplayFor(modelItem => item.LockoutEnabled) + + @Html.DisplayFor(modelItem => item.LockoutEnd) + + @Html.DisplayFor(modelItem => item.NormalizedEmail) + + @Html.DisplayFor(modelItem => item.NormalizedUserName) + + @Html.DisplayFor(modelItem => item.PasswordHash) + + @Html.DisplayFor(modelItem => item.PhoneNumber) + + @Html.DisplayFor(modelItem => item.PhoneNumberConfirmed) + + @Html.DisplayFor(modelItem => item.SecurityStamp) + + @Html.DisplayFor(modelItem => item.TwoFactorEnabled) + + @Html.DisplayFor(modelItem => item.UserName) + + Edit | + Details | + Delete +