- Manage Roles Index action,view,model for Roles

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4039480
This commit is contained in:
suhacan
2009-11-10 20:36:20 +00:00
parent 1a839b1ae1
commit 94e415b064
6 changed files with 86 additions and 10 deletions

View File

@@ -28,7 +28,7 @@
<span class="filterActions"> <span class="filterActions">
<%=Html.ActionLink("Add a new folder", "Create") %> <%=Html.ActionLink("Add a new folder", "Create") %>
</span> </span>
<table id="Table1" cellspacing="0" class="roundCorners clearLayout" summary="This is a table of the pages currently available for use in your application."> <table id="Table1" cellspacing="0" class="roundCorners clearLayout" summary="This is a table of the media folders currently available for use in your application.">
<colgroup> <colgroup>
<col id="Col1" /> <col id="Col1" />
<col id="Col2" /> <col id="Col2" />

View File

@@ -1,18 +1,31 @@
using System.Web.Mvc; using System.Linq;
using System.Web.Mvc;
using Orchard.Data;
using Orchard.Notify; using Orchard.Notify;
using Orchard.Roles.Models;
using Orchard.Roles.ViewModels;
namespace Orchard.Roles.Controllers { namespace Orchard.Roles.Controllers {
[ValidateInput(false)] [ValidateInput(false)]
public class AdminController : Controller { public class AdminController : Controller {
private readonly IRepository<RoleRecord> _roleRepository;
private readonly INotifier _notifier; private readonly INotifier _notifier;
public AdminController(INotifier notifier) { public AdminController(IRepository<RoleRecord> roleRepository, INotifier notifier) {
_roleRepository = roleRepository;
_notifier = notifier; _notifier = notifier;
} }
public ActionResult Index() { public ActionResult Index() {
return View(); var model = new RolesIndexViewModel {
Rows = _roleRepository.Fetch(x => x.Name != null)
.Select(x => new RolesIndexViewModel.Row {
Role = x
})
.ToList()
};
return View(model);
} }
} }
} }

View File

@@ -66,9 +66,11 @@
<Compile Include="Models\RoleRecord.cs" /> <Compile Include="Models\RoleRecord.cs" />
<Compile Include="Models\RolesPermissions.cs" /> <Compile Include="Models\RolesPermissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\RolesIndexViewModel.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Package.txt" /> <Content Include="Package.txt" />
<Content Include="Views\Admin\Index.aspx" />
<Content Include="Web.config" /> <Content Include="Web.config" />
<Content Include="Content\Site.css" /> <Content Include="Content\Site.css" />
<Content Include="Views\Web.config" /> <Content Include="Views\Web.config" />
@@ -81,7 +83,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="App_Data\" /> <Folder Include="App_Data\" />
<Folder Include="Views\Admin\" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
using Orchard.Mvc.ViewModels;
using Orchard.Roles.Models;
namespace Orchard.Roles.ViewModels {
public class RolesIndexViewModel : AdminViewModel {
public class Row {
public RoleRecord Role { get; set; }
}
public IList<Row> Rows { get; set; }
}
}

View File

@@ -0,0 +1,52 @@
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Orchard.Roles.ViewModels.RolesIndexViewModel>" %>
<%@ Import Namespace="Orchard.Mvc.Html" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Manage Roles</title>
<% Html.Include("Head"); %>
</head>
<body>
<% Html.Include("Header"); %>
<% Html.BeginForm(); %>
<div class="yui-g">
<h2 class="separator">Manage Roles</h2>
<ol class="horizontal actions floatLeft">
<li><label class="floatLeft" for="bulkActions">Actions:</label>
<select id="Select1" name="roleActions">
<option value="1">Delete</option>
</select> </li>
<li>
<input class="button roundCorners" type="submit" value="Apply" />
</li>
</ol>
<%=Html.ValidationSummary() %>
<%=Html.ActionLink("Add a new role", "Create", new {}, new {@class="floatRight topSpacer"}) %>
<table id="Table1" cellspacing="0" class="roundCorners clearLayout" summary="This is a table of the roles currently available for use in your application.">
<colgroup>
<col id="Col1" />
<col id="Col2" />
<col id="Col3" />
</colgroup>
<thead>
<tr>
<th scope="col"><%--<input type="checkbox" value="" />--%></th>
<th scope="col">Name</th>
<th scope="col"></th>
</tr>
</thead>
<%foreach (var row in Model.Rows) { %>
<tr>
<td><input type="checkbox" value="true" name="<%= "Checkbox." + row.Role.Name %>"/></td>
<td><%=Html.Encode(row.Role.Name) %></td>
<td><%=Html.ActionLink("Edit", "Edit", new { row.Role.Id })%></td>
</tr>
<%}%>
</table>
</div>
<% Html.EndForm(); %>
<% Html.Include("Footer"); %>
</body>
</html>

View File

@@ -1,7 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Mvc.ViewModels; using Orchard.Mvc.ViewModels;
using Orchard.Users.Models; using Orchard.Users.Models;