mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-16 14:37:08 +08:00
Implementing Users AdminController and views
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4039450
This commit is contained in:
parent
2287a33aad
commit
a3f0598057
69
src/Orchard.Tests.Packages/DatabaseEnabledTestsBase.cs
Normal file
69
src/Orchard.Tests.Packages/DatabaseEnabledTestsBase.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Autofac;
|
||||||
|
using Autofac.Builder;
|
||||||
|
using Autofac.Modules;
|
||||||
|
using NHibernate;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Orchard.Data;
|
||||||
|
using Orchard.Services;
|
||||||
|
using Orchard.Tests.Data;
|
||||||
|
using Orchard.Tests.Stubs;
|
||||||
|
|
||||||
|
namespace Orchard.Tests.Packages {
|
||||||
|
public abstract class DatabaseEnabledTestsBase {
|
||||||
|
|
||||||
|
protected IContainer _container;
|
||||||
|
|
||||||
|
protected ISession _session;
|
||||||
|
protected string _databaseFilePath;
|
||||||
|
protected ISessionFactory _sessionFactory;
|
||||||
|
protected StubClock _clock;
|
||||||
|
|
||||||
|
|
||||||
|
[TestFixtureSetUp]
|
||||||
|
public void InitFixture() {
|
||||||
|
_databaseFilePath = Path.GetTempFileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixtureTearDown]
|
||||||
|
public void TearDownFixture() {
|
||||||
|
File.Delete(_databaseFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public virtual void Init() {
|
||||||
|
_sessionFactory = DataUtility.CreateSessionFactory(_databaseFilePath, DatabaseTypes.ToArray());
|
||||||
|
_session = _sessionFactory.OpenSession();
|
||||||
|
_clock = new StubClock();
|
||||||
|
|
||||||
|
var builder = new ContainerBuilder();
|
||||||
|
builder.RegisterModule(new ImplicitCollectionSupportModule());
|
||||||
|
builder.Register(new StubLocator(_session)).As<ISessionLocator>();
|
||||||
|
builder.Register(_clock).As<IClock>();
|
||||||
|
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||||
|
Register(builder);
|
||||||
|
_container = builder.Build();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TearDown]
|
||||||
|
public void Cleanup() {
|
||||||
|
_session.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void Register(ContainerBuilder builder);
|
||||||
|
|
||||||
|
protected virtual IEnumerable<Type> DatabaseTypes {
|
||||||
|
get {
|
||||||
|
return Enumerable.Empty<Type>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void ClearSession() {
|
||||||
|
_session.Flush();
|
||||||
|
_session.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -39,6 +39,10 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\lib\fluentnhibernate\FluentNHibernate.dll</HintPath>
|
<HintPath>..\..\lib\fluentnhibernate\FluentNHibernate.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\lib\moq\Moq.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
<Reference Include="NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\lib\fluentnhibernate\NHibernate.dll</HintPath>
|
<HintPath>..\..\lib\fluentnhibernate\NHibernate.dll</HintPath>
|
||||||
@ -60,10 +64,16 @@
|
|||||||
<HintPath>..\..\lib\sqlite\System.Data.SQLite.DLL</HintPath>
|
<HintPath>..\..\lib\sqlite\System.Data.SQLite.DLL</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Web.Abstractions">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
|
<HintPath>..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Web.Routing">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Xml.Linq">
|
<Reference Include="System.Xml.Linq">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -74,7 +84,9 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="DatabaseEnabledTestsBase.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Users\Controllers\AdminControllerTests.cs" />
|
||||||
<Compile Include="Users\Services\MembershipServiceTests.cs" />
|
<Compile Include="Users\Services\MembershipServiceTests.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -0,0 +1,102 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Web.Routing;
|
||||||
|
using Autofac.Builder;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Orchard.Data;
|
||||||
|
using Orchard.Models;
|
||||||
|
using Orchard.Models.Driver;
|
||||||
|
using Orchard.Models.Records;
|
||||||
|
using Orchard.Notify;
|
||||||
|
using Orchard.Security;
|
||||||
|
using Orchard.Users.Controllers;
|
||||||
|
using Orchard.Users.Models;
|
||||||
|
using Orchard.Users.ViewModels;
|
||||||
|
|
||||||
|
namespace Orchard.Tests.Packages.Users.Controllers {
|
||||||
|
[TestFixture]
|
||||||
|
public class AdminControllerTests : DatabaseEnabledTestsBase {
|
||||||
|
private AdminController _controller;
|
||||||
|
|
||||||
|
public override void Register(ContainerBuilder builder) {
|
||||||
|
builder.Register<AdminController>();
|
||||||
|
builder.Register<DefaultModelManager>().As<IModelManager>();
|
||||||
|
builder.Register<UserDriver>().As<IModelDriver>();
|
||||||
|
builder.Register(new Moq.Mock<INotifier>().Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<Type> DatabaseTypes {
|
||||||
|
get {
|
||||||
|
return new[] { typeof(UserRecord), typeof(ModelRecord), typeof(ModelTypeRecord) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Init() {
|
||||||
|
base.Init();
|
||||||
|
|
||||||
|
var manager = _container.Resolve<IModelManager>();
|
||||||
|
|
||||||
|
var userOne = manager.New("user").As<UserModel>();
|
||||||
|
userOne.Record = new UserRecord { UserName = "one" };
|
||||||
|
manager.Create(userOne);
|
||||||
|
|
||||||
|
var userTwo = manager.New("user").As<UserModel>();
|
||||||
|
userTwo.Record = new UserRecord { UserName = "two" };
|
||||||
|
manager.Create(userTwo);
|
||||||
|
|
||||||
|
var userThree = manager.New("user").As<UserModel>();
|
||||||
|
userThree.Record = new UserRecord { UserName = "three" };
|
||||||
|
manager.Create(userThree);
|
||||||
|
|
||||||
|
_controller = _container.Resolve<AdminController>();
|
||||||
|
|
||||||
|
var mockHttpContext = new Mock<HttpContextBase>();
|
||||||
|
_controller.ControllerContext = new ControllerContext(
|
||||||
|
mockHttpContext.Object,
|
||||||
|
new RouteData(
|
||||||
|
new Route("foo", new MvcRouteHandler()),
|
||||||
|
new MvcRouteHandler()),
|
||||||
|
_controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IndexShouldReturnRowsForUsers() {
|
||||||
|
var controller = _container.Resolve<AdminController>();
|
||||||
|
var result = (ViewResult)controller.Index();
|
||||||
|
var model = (UsersIndexViewModel)result.ViewData.Model;
|
||||||
|
|
||||||
|
Assert.That(model.Rows, Is.Not.Null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CreateShouldAddUserAndRedirect() {
|
||||||
|
var controller = _container.Resolve<AdminController>();
|
||||||
|
var result = controller.Create(new UserCreateViewModel { UserName = "four" });
|
||||||
|
Assert.That(result, Is.TypeOf<RedirectToRouteResult>());
|
||||||
|
|
||||||
|
var redirect = (RedirectToRouteResult)result;
|
||||||
|
var id = Convert.ToInt32(redirect.RouteValues["id"]);
|
||||||
|
var manager = _container.Resolve<IModelManager>();
|
||||||
|
var user = manager.Get(id).As<IUser>();
|
||||||
|
Assert.That(user.UserName, Is.EqualTo("four"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EditShouldDisplayUserAndStoreChanges() {
|
||||||
|
var repository = _container.Resolve<IRepository<UserRecord>>();
|
||||||
|
var id = repository.Get(x => x.UserName == "two").Id;
|
||||||
|
var result = (ViewResult)_container.Resolve<AdminController>().Edit(id);
|
||||||
|
var model = (UserEditViewModel)result.ViewData.Model;
|
||||||
|
Assert.That(model.UserName, Is.EqualTo("two"));
|
||||||
|
|
||||||
|
var input = new FormCollection { { "UserName", "bubba" }, { "Email", "hotep" } };
|
||||||
|
var result2 = _container.Resolve<AdminController>().Edit(id, input);
|
||||||
|
Assert.That(result2, Is.TypeOf<RedirectToRouteResult>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,67 @@
|
|||||||
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
using Orchard.Data;
|
||||||
|
using Orchard.Models;
|
||||||
|
using Orchard.Notify;
|
||||||
|
using Orchard.Users.Models;
|
||||||
|
using Orchard.Users.ViewModels;
|
||||||
|
|
||||||
namespace Orchard.Users.Controllers {
|
namespace Orchard.Users.Controllers {
|
||||||
public class AdminController : Controller {
|
public class AdminController : Controller {
|
||||||
public ActionResult Index() {
|
private readonly IModelManager _modelManager;
|
||||||
return View();
|
private readonly IRepository<UserRecord> _userRepository;
|
||||||
|
private readonly INotifier _notifier;
|
||||||
|
|
||||||
|
public AdminController(
|
||||||
|
IModelManager modelManager,
|
||||||
|
IRepository<UserRecord> userRepository,
|
||||||
|
INotifier notifier) {
|
||||||
|
_modelManager = modelManager;
|
||||||
|
_userRepository = userRepository;
|
||||||
|
_notifier = notifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResult Index() {
|
||||||
|
var model = new UsersIndexViewModel();
|
||||||
|
model.Rows = _userRepository.Fetch(x => x.UserName != null)
|
||||||
|
.Select(x => new UsersIndexViewModel.Row {
|
||||||
|
User = _modelManager.Get(x.Id).As<UserModel>()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult Create() {
|
||||||
|
var model = new UserCreateViewModel();
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public ActionResult Create(UserCreateViewModel model) {
|
||||||
|
if (ModelState.IsValid == false) {
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
var user = _modelManager.New("user");
|
||||||
|
user.As<UserModel>().Record = new UserRecord { UserName = model.UserName, Email = model.Email };
|
||||||
|
_modelManager.Create(user);
|
||||||
|
return RedirectToAction("edit", new { user.Id });
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult Edit(int id) {
|
||||||
|
var model = new UserEditViewModel { User = _modelManager.Get(id) };
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public ActionResult Edit(int id, FormCollection input) {
|
||||||
|
var model = new UserEditViewModel { User = _modelManager.Get(id) };
|
||||||
|
if (!TryUpdateModel(model, input.ToValueProvider())) {
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
_notifier.Information("User information updated");
|
||||||
|
return RedirectToAction("Edit", new { id });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,18 @@
|
|||||||
<Compile Include="Models\UserRecord.cs" />
|
<Compile Include="Models\UserRecord.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Services\MembershipService.cs" />
|
<Compile Include="Services\MembershipService.cs" />
|
||||||
|
<Compile Include="ViewModels\UserCreateViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\UserEditViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\UsersIndexViewModel.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Package.txt" />
|
<Content Include="Package.txt" />
|
||||||
|
<Content Include="Views\Admin\Edit.aspx" />
|
||||||
|
<Content Include="Views\Admin\Create.aspx" />
|
||||||
|
<Content Include="Views\Admin\EditorTemplates\UserEditViewModel.ascx" />
|
||||||
|
<Content Include="Views\Admin\EditorTemplates\inputTextLarge.ascx" />
|
||||||
|
<Content Include="Views\Admin\EditorTemplates\UserCreateViewModel.ascx" />
|
||||||
|
<Content Include="Views\Admin\Index.aspx" />
|
||||||
<Content Include="Web.config" />
|
<Content Include="Web.config" />
|
||||||
<Content Include="Views\Web.config" />
|
<Content Include="Views\Web.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Orchard.Mvc.ViewModels;
|
||||||
|
|
||||||
|
namespace Orchard.Users.ViewModels {
|
||||||
|
public class UserCreateViewModel : AdminViewModel {
|
||||||
|
[Required]
|
||||||
|
public string UserName { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Email { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Orchard.Models;
|
||||||
|
using Orchard.Mvc.ViewModels;
|
||||||
|
using Orchard.Users.Models;
|
||||||
|
|
||||||
|
namespace Orchard.Users.ViewModels {
|
||||||
|
public class UserEditViewModel : AdminViewModel {
|
||||||
|
public IModel User { get; set; }
|
||||||
|
|
||||||
|
[HiddenInput(DisplayValue = false)]
|
||||||
|
public int Id {
|
||||||
|
get { return User.Id; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string UserName {
|
||||||
|
get { return User.As<UserModel>().Record.UserName; }
|
||||||
|
set { User.As<UserModel>().Record.UserName = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Email {
|
||||||
|
get { return User.As<UserModel>().Record.Email; }
|
||||||
|
set { User.As<UserModel>().Record.Email = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using Orchard.Mvc.ViewModels;
|
||||||
|
using Orchard.Users.Models;
|
||||||
|
|
||||||
|
namespace Orchard.Users.ViewModels {
|
||||||
|
|
||||||
|
public class UsersIndexViewModel : AdminViewModel {
|
||||||
|
public class Row {
|
||||||
|
public UserModel User { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<Row> Rows { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Orchard.Users.ViewModels.UserCreateViewModel>" %>
|
||||||
|
|
||||||
|
<%@ Import Namespace="Orchard.Security" %>
|
||||||
|
<%@ 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 runat="server">
|
||||||
|
<title>Add a new User</title>
|
||||||
|
<% Html.Include("Head"); %>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<% Html.Include("Header"); %>
|
||||||
|
<div class="yui-u">
|
||||||
|
<h2 class="separator">
|
||||||
|
Add a new User</h2>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="yui-u">
|
||||||
|
<%using (Html.BeginForm()) { %>
|
||||||
|
<ol>
|
||||||
|
<%= Html.ValidationSummary() %>
|
||||||
|
<%= Html.EditorForModel() %>
|
||||||
|
<li class="clearLayout">
|
||||||
|
<input class="button" type="submit" value="Create" />
|
||||||
|
<%=Html.ActionLink("Cancel", "Index", new{}, new{@class="button"}) %></li>
|
||||||
|
</ol>
|
||||||
|
<%}/*EndForm*/%>
|
||||||
|
</div>
|
||||||
|
<% Html.Include("Footer"); %>
|
||||||
|
</body>
|
||||||
|
</html>
|
34
src/Orchard.Web/Packages/Orchard.Users/Views/Admin/Edit.aspx
Normal file
34
src/Orchard.Web/Packages/Orchard.Users/Views/Admin/Edit.aspx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Orchard.Users.ViewModels.UserEditViewModel>" %>
|
||||||
|
|
||||||
|
<%@ Import Namespace="Orchard.Security" %>
|
||||||
|
<%@ 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 runat="server">
|
||||||
|
<title>Edit User</title>
|
||||||
|
<% Html.Include("Head"); %>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<% Html.Include("Header"); %>
|
||||||
|
<div class="yui-u">
|
||||||
|
<h2 class="separator">
|
||||||
|
Edit User</h2>
|
||||||
|
<p class="bottomSpacer">
|
||||||
|
<%=Html.ActionLink("Users", "Index") %> > Edit #<%=Model.Id%> <strong><%=Html.Encode(Model.UserName)%></strong>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="yui-u">
|
||||||
|
<%using (Html.BeginForm()) { %>
|
||||||
|
<ol>
|
||||||
|
<%= Html.ValidationSummary() %>
|
||||||
|
<%= Html.EditorForModel() %>
|
||||||
|
<li class="clearLayout">
|
||||||
|
<input class="button" type="submit" value="Save" />
|
||||||
|
<%=Html.ActionLink("Cancel", "Index", new{}, new{@class="button"}) %>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<%}/*EndForm*/%>
|
||||||
|
</div>
|
||||||
|
<% Html.Include("Footer"); %>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,7 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Orchard.Users.ViewModels.UserCreateViewModel>" %>
|
||||||
|
<%@ Import Namespace="Orchard.Utility" %>
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
<%=Html.EditorFor(m=>m.UserName, "inputTextLarge") %>
|
||||||
|
<%=Html.EditorFor(m=>m.Email, "inputTextLarge") %>
|
||||||
|
</ol>
|
@ -0,0 +1,8 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Orchard.Users.ViewModels.UserEditViewModel>" %>
|
||||||
|
<%@ Import Namespace="Orchard.Utility" %>
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
<%=Html.EditorFor(m=>m.Id) %>
|
||||||
|
<%=Html.EditorFor(m=>m.UserName, "inputTextLarge") %>
|
||||||
|
<%=Html.EditorFor(m=>m.Email, "inputTextLarge") %>
|
||||||
|
</ol>
|
@ -0,0 +1,6 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %>
|
||||||
|
<li>
|
||||||
|
<%=Html.LabelForModel() %>
|
||||||
|
<%=Html.TextBox("",Model,new{@class="inputText inputTextLarge"}) %>
|
||||||
|
<%=Html.ValidationMessage("","*")%>
|
||||||
|
</li>
|
@ -0,0 +1,56 @@
|
|||||||
|
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Orchard.Users.ViewModels.UsersIndexViewModel>" %>
|
||||||
|
|
||||||
|
<%@ Import Namespace="Orchard.Security" %>
|
||||||
|
<%@ 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 runat="server">
|
||||||
|
<title>Manage Users</title>
|
||||||
|
<% Html.Include("Head"); %>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<% Html.Include("Header"); %>
|
||||||
|
<% Html.BeginForm(); %>
|
||||||
|
<div class="yui-g">
|
||||||
|
<h2>
|
||||||
|
Manage Users</h2>
|
||||||
|
|
||||||
|
<%=Html.ValidationSummary() %>
|
||||||
|
<%=Html.ActionLink("Add a new user", "Create", new {}, new {@class="floatRight topSpacer"}) %>
|
||||||
|
<table id="pluginListTable" cellspacing="0" class="clearLayout">
|
||||||
|
<colgroup>
|
||||||
|
<col id="Name" />
|
||||||
|
<col id="Email" />
|
||||||
|
<col id="Edit" />
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">
|
||||||
|
Name
|
||||||
|
</th>
|
||||||
|
<th scope="col">
|
||||||
|
Email
|
||||||
|
</th>
|
||||||
|
<th scope="col">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<% foreach (var row in Model.Rows) { %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<%=Html.Encode(row.User.As<IUser>().UserName) %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%=Html.Encode(row.User.As<IUser>().Email) %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%=Html.ActionLink("Edit", "Edit", new { row.User.Id })%>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<%}%>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<% Html.EndForm(); %>
|
||||||
|
<% Html.Include("Footer"); %>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -23,11 +23,6 @@
|
|||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
</configSections>
|
</configSections>
|
||||||
|
|
||||||
<appSettings/>
|
|
||||||
|
|
||||||
<connectionStrings>
|
|
||||||
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
|
|
||||||
</connectionStrings>
|
|
||||||
|
|
||||||
<system.web>
|
<system.web>
|
||||||
|
|
||||||
@ -37,7 +32,7 @@
|
|||||||
affects performance, set this value to true only
|
affects performance, set this value to true only
|
||||||
during development.
|
during development.
|
||||||
-->
|
-->
|
||||||
<compilation debug="false">
|
<compilation debug="true">
|
||||||
<assemblies>
|
<assemblies>
|
||||||
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||||
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||||
@ -50,54 +45,7 @@
|
|||||||
</assemblies>
|
</assemblies>
|
||||||
</compilation>
|
</compilation>
|
||||||
|
|
||||||
<!--
|
|
||||||
The <authentication> section enables configuration
|
|
||||||
of the security authentication mode used by
|
|
||||||
ASP.NET to identify an incoming user.
|
|
||||||
-->
|
|
||||||
<authentication mode="Forms">
|
|
||||||
<forms loginUrl="~/Account/LogOn" timeout="2880" />
|
|
||||||
</authentication>
|
|
||||||
|
|
||||||
<membership>
|
|
||||||
<providers>
|
|
||||||
<clear/>
|
|
||||||
<add name="AspNetSqlMembershipProvider"
|
|
||||||
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
|
|
||||||
connectionStringName="ApplicationServices"
|
|
||||||
enablePasswordRetrieval="false"
|
|
||||||
enablePasswordReset="true"
|
|
||||||
requiresQuestionAndAnswer="false"
|
|
||||||
requiresUniqueEmail="false"
|
|
||||||
passwordFormat="Hashed"
|
|
||||||
maxInvalidPasswordAttempts="5"
|
|
||||||
minRequiredPasswordLength="6"
|
|
||||||
minRequiredNonalphanumericCharacters="0"
|
|
||||||
passwordAttemptWindow="10"
|
|
||||||
passwordStrengthRegularExpression=""
|
|
||||||
applicationName="/"
|
|
||||||
/>
|
|
||||||
</providers>
|
|
||||||
</membership>
|
|
||||||
|
|
||||||
<profile>
|
|
||||||
<providers>
|
|
||||||
<clear/>
|
|
||||||
<add name="AspNetSqlProfileProvider"
|
|
||||||
type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
|
|
||||||
connectionStringName="ApplicationServices"
|
|
||||||
applicationName="/"
|
|
||||||
/>
|
|
||||||
</providers>
|
|
||||||
</profile>
|
|
||||||
|
|
||||||
<roleManager enabled="false">
|
|
||||||
<providers>
|
|
||||||
<clear />
|
|
||||||
<add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
|
||||||
<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
|
||||||
</providers>
|
|
||||||
</roleManager>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
The <customErrors> section enables configuration
|
The <customErrors> section enables configuration
|
||||||
|
Loading…
Reference in New Issue
Block a user