refactoring: --YavscLib-- => Yavsc

This commit is contained in:
Paul Schneider 2017-05-27 16:22:58 +02:00
commit 776b7dae21
102 changed files with 216 additions and 209 deletions

View file

@ -20,7 +20,7 @@ using Microsoft.Data.Entity;
namespace Yavsc.Controllers
{
[AllowAnonymous]
public class AccountController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
@ -61,6 +61,13 @@ namespace Yavsc.Controllers
_dbContext = dbContext;
}
[Authorize(Roles=Constants.AdminGroupName)]
public async Task<IActionResult> UserList ()
{
return View(await _dbContext.Users.ToArrayAsync());
}
[AllowAnonymous]
[HttpGet(Constants.LoginPath)]
public ActionResult SignIn(string returnUrl = null)
{
@ -79,6 +86,7 @@ namespace Yavsc.Controllers
*/
}
[AllowAnonymous]
public ActionResult AccessDenied(string requestUrl = null)
{
ViewBag.UserIsSignedIn = User.IsSignedIn();
@ -89,6 +97,7 @@ namespace Yavsc.Controllers
return View("AccessDenied",requestUrl);
}
[AllowAnonymous]
[HttpPost(Constants.LoginPath)]
public async Task<IActionResult> SignIn(SignInViewModel model)
{
@ -169,6 +178,7 @@ namespace Yavsc.Controllers
//
// GET: /Account/Register
[AllowAnonymous]
[HttpGet]
public IActionResult Register()
{
@ -178,6 +188,7 @@ namespace Yavsc.Controllers
//
// POST: /Account/Register
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Register(RegisterViewModel model)
{
@ -220,6 +231,7 @@ namespace Yavsc.Controllers
//
// GET: /Account/ExternalLoginCallback
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null)
{
var info = await _signInManager.GetExternalLoginInfoAsync();
@ -285,6 +297,7 @@ namespace Yavsc.Controllers
// POST: /Account/ExternalLoginConfirmation
[HttpPost]
[ValidateAntiForgeryToken]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl = null)
{
if (User.IsSignedIn())
@ -324,6 +337,7 @@ namespace Yavsc.Controllers
// GET: /Account/ConfirmEmail
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ConfirmEmail(string userId, string code)
{
if (userId == null || code == null)
@ -342,6 +356,7 @@ namespace Yavsc.Controllers
//
// GET: /Account/ForgotPassword
[HttpGet]
[AllowAnonymous]
public IActionResult ForgotPassword()
{
return View();
@ -350,6 +365,7 @@ namespace Yavsc.Controllers
//
// POST: /Account/ForgotPassword
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<IActionResult> ForgotPassword(ForgotPasswordViewModel model)
{
@ -382,6 +398,7 @@ namespace Yavsc.Controllers
//
// GET: /Account/ForgotPasswordConfirmation
[HttpGet]
[AllowAnonymous]
public IActionResult ForgotPasswordConfirmation()
{
return View();
@ -390,6 +407,7 @@ namespace Yavsc.Controllers
//
// GET: /Account/ResetPassword
[HttpGet]
[AllowAnonymous]
public IActionResult ResetPassword(string UserId, string code = null)
{
return code == null ? View("Error") : View();
@ -398,6 +416,7 @@ namespace Yavsc.Controllers
//
// POST: /Account/ResetPassword
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<IActionResult> ResetPassword(ResetPasswordViewModel model)
{
@ -423,6 +442,7 @@ namespace Yavsc.Controllers
//
// GET: /Account/ResetPasswordConfirmation
[HttpGet]
[AllowAnonymous]
public IActionResult ResetPasswordConfirmation()
{
return View();
@ -489,6 +509,7 @@ namespace Yavsc.Controllers
//
// GET: /Account/VerifyCode
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> VerifyCode(string provider, bool rememberMe, string returnUrl = null)
{
// Require that the user has already logged in via username/password or external login
@ -503,6 +524,7 @@ namespace Yavsc.Controllers
//
// POST: /Account/VerifyCode
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<IActionResult> VerifyCode(VerifyCodeViewModel model)
{

View file

@ -81,6 +81,7 @@ namespace Yavsc.Controllers
{
var adminCount = await _userManager.GetUsersInRoleAsync(
Constants.AdminGroupName);
var userCount = await context.Users.CountAsync();
var youAreAdmin = await _userManager.IsInRoleAsync(
await _userManager.FindByIdAsync(User.GetUserId()),
Constants.AdminGroupName);
@ -98,7 +99,8 @@ namespace Yavsc.Controllers
{
Roles = roles.ToArray(),
AdminCount = adminCount.Count,
YouAreAdmin = youAreAdmin
YouAreAdmin = youAreAdmin,
UserCount = userCount
});
}

View file

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
using Models.Workflow;
using Yavsc.Exceptions;
using Yavsc.ViewModels.Workflow;
using YavscLib;
using Yavsc;
[Authorize]
public class DoController : Controller
@ -22,7 +22,7 @@ namespace Yavsc.Controllers
public DoController(ApplicationDbContext context,ILogger<DoController> logger)
{
_context = context;
_context = context;
_logger = logger;
}
@ -42,7 +42,7 @@ namespace Yavsc.Controllers
// GET: Do/Details/5
public IActionResult Details(string id, string activityCode)
{
if (id == null || activityCode == null)
{
return HttpNotFound();
@ -54,20 +54,20 @@ namespace Yavsc.Controllers
{
return HttpNotFound();
}
bool hasConfigurableSettings = (userActivity.Does.SettingsClassName != null);
if (hasConfigurableSettings) {
ViewBag.ProfileType = Startup.ProfileTypes.Single(t=>t.FullName==userActivity.Does.SettingsClassName);
var dbset = (IQueryable<ISpecializationSettings>) _context.GetDbSet(userActivity.Does.SettingsClassName);
if (dbset == null) throw new InvalidWorkflowModelException($"pas de db set pour {userActivity.Does.SettingsClassName}, vous avez peut-être besoin de décorer votre propriété avec l'attribut [ActivitySettings]");
return View(new UserActivityViewModel {
Declaration = userActivity,
return View(new UserActivityViewModel {
Declaration = userActivity,
HasSettings = dbset.Any(ua=>ua.UserId==id),
NeedsSettings = hasConfigurableSettings
} );
}
return View(new UserActivityViewModel {
Declaration = userActivity,
return View(new UserActivityViewModel {
Declaration = userActivity,
HasSettings = false,
NeedsSettings = hasConfigurableSettings
} );

View file

@ -5,7 +5,7 @@ using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity;
using Yavsc.Exceptions;
using Yavsc.Models;
using YavscLib;
using Yavsc;
namespace Yavsc.Controllers.Generic
{
@ -15,7 +15,7 @@ namespace Yavsc.Controllers.Generic
protected ApplicationDbContext _context;
private object dbSet;
protected DbSet<TSettings> Settings { get {
protected DbSet<TSettings> Settings { get {
return (DbSet<TSettings>) dbSet;
} }
@ -47,7 +47,7 @@ namespace Yavsc.Controllers.Generic
return View(profile);
}
// GET: BrusherProfile/Create
public IActionResult Create()
@ -71,7 +71,7 @@ namespace Yavsc.Controllers.Generic
return View(setting);
}
// GET: BrusherProfile/Delete/5
[ActionName("Delete")]
@ -106,7 +106,7 @@ namespace Yavsc.Controllers.Generic
}
return View("Edit",settings);
}
// POST: FormationSettings/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
@ -115,7 +115,7 @@ namespace Yavsc.Controllers.Generic
if (settings.UserId == null) {
settings.UserId = User.GetUserId();
Settings.Add(settings);
} else
} else
_context.Update(settings);
if (ModelState.IsValid)
{
@ -124,7 +124,7 @@ namespace Yavsc.Controllers.Generic
}
return View(settings);
}
// POST: FormationSettings/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
@ -137,4 +137,4 @@ namespace Yavsc.Controllers.Generic
}
}
}
}

View file

@ -14,7 +14,7 @@ using System.Threading.Tasks;
namespace Yavsc.Controllers
{
using Models;
using YavscLib;
using Yavsc;
[AllowAnonymous]
public class HomeController : Controller