Filter users by active/disabled
This commit is contained in:
@@ -15,15 +15,18 @@ namespace MileageTraker.Web.Controllers
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
public ActionResult Index()
|
||||
public ActionResult Index(bool disabled = false)
|
||||
{
|
||||
var users =
|
||||
DataService
|
||||
.GetUsers()
|
||||
.ToList()
|
||||
.OrderBy(u => u.Username);
|
||||
var users =
|
||||
from u in DataService.GetUsers()
|
||||
where u.IsApproved == !disabled
|
||||
orderby u.Username
|
||||
select u;
|
||||
|
||||
return View(users);
|
||||
var userResultsViewModel = new UserResultsViewModel(users.ToList(), disabled);
|
||||
|
||||
|
||||
return View(userResultsViewModel);
|
||||
}
|
||||
|
||||
[ActionLog]
|
||||
|
||||
@@ -6,7 +6,6 @@ using MileageTraker.Web.DAL;
|
||||
using MileageTraker.Web.Models;
|
||||
using MileageTraker.Web.Utility;
|
||||
using MileageTraker.Web.ViewModels.Vehicle;
|
||||
using MileageTraker.Web.ViewModels.VehicleService;
|
||||
|
||||
namespace MileageTraker.Web.Controllers
|
||||
{
|
||||
|
||||
@@ -213,6 +213,7 @@ function addButtonIcons () {
|
||||
'Vehicle Mileage': 'car',
|
||||
'Show Active': 'check-circle',
|
||||
'Show Inactive': 'ban',
|
||||
'Show Disabled Accts': 'ban',
|
||||
'Set Inactive' : 'ban',
|
||||
'Reactivate': 'check-circle',
|
||||
'Config': 'cog',
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.User
|
||||
{
|
||||
public class UserResultsViewModel
|
||||
{
|
||||
public IEnumerable<Models.User> Users { get; set; }
|
||||
public bool Disabled { get; }
|
||||
|
||||
public UserResultsViewModel(IEnumerable<Models.User> users, bool disabled)
|
||||
{
|
||||
Users = users;
|
||||
Disabled = disabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
@using MileageTraker.Web.Models
|
||||
@model IEnumerable<User>
|
||||
@model MileageTraker.Web.ViewModels.User.UserResultsViewModel
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Users";
|
||||
var grid = new WebGrid(Model, rowsPerPage: 45);
|
||||
var grid = new WebGrid(Model.Users, rowsPerPage: 45);
|
||||
}
|
||||
|
||||
@Html.Partial("_StatusMessage")
|
||||
@@ -20,6 +20,8 @@
|
||||
<div class="btn-toolbar pull-left">
|
||||
@Html.ActionLink("Add new User", "Create", null, new{@class="btn"})
|
||||
@Html.ActionLink("Export", "Export", null, new{@class="btn"})
|
||||
@Html.ActionLink(Model.Disabled ? "Show Active" : "Show Disabled Accts", "Index", new {disabled = !Model.Disabled}, new { @class = "btn" })
|
||||
|
||||
@if (User.IsInRole("Developer"))
|
||||
{
|
||||
@Html.ActionLink("Invite Uninintialized", "InviteUninitialized", null, new{@class="btn"})
|
||||
|
||||
@@ -166,6 +166,7 @@
|
||||
<Compile Include="Email\ServiceReminderEmailService.cs" />
|
||||
<Compile Include="Startup.cs" />
|
||||
<Compile Include="ViewModels\DriverMileageFlattenedViewModel.cs" />
|
||||
<Compile Include="ViewModels\User\UserResultsViewModel.cs" />
|
||||
<Compile Include="ViewModels\VehicleService\VehicleSelectViewModel.cs" />
|
||||
<Compile Include="ViewModels\VehicleService\UpdateServiceRemindersViewModel.cs" />
|
||||
<Compile Include="Controllers\FuelLogController.cs" />
|
||||
|
||||
Reference in New Issue
Block a user