From 90689dbb0e9fdd3349eb691b1d230b774c3490e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Vondr=C3=A1=C5=A1ek?= Date: Sat, 4 Jul 2015 23:34:59 +0200 Subject: [PATCH] Added controllers, views, queries etc for Positions and Roles (not compilable yet, though). Relates to #27 --- .../BusinessLogic/BusinessLogic.csproj | 4 + .../Contracts/IPositionsRepository.cs | 18 ++++ .../Security/Contracts/IRolesRepository.cs | 18 ++++ .../Domain/Security/Contracts/ISecurityUow.cs | 4 + .../Security/Queries/PositionQueries.cs | 27 ++++++ .../Domain/Security/Queries/RoleQueries.cs | 27 ++++++ .../Database/Database.csproj | 2 + .../Database/Security/PositionsRepository.cs | 38 ++++++++ .../Database/Security/RolesRepository.cs | 38 ++++++++ .../Database/Security/SecurityDbContext.cs | 2 + .../Database/Security/SecurityUow.cs | 10 ++ .../Controllers/PositionsController.cs | 93 ++++++++++++++++++ .../Security/Controllers/RolesController.cs | 94 +++++++++++++++++++ .../Security/Models/Positions/IndexFilter.cs | 33 +++++++ .../Security/Models/Roles/IndexFilter.cs | 33 +++++++ .../Security/Models/Users/IndexFilter.cs | 1 - .../Security/Views/Positions/Detail.cshtml | 17 ++++ .../Security/Views/Positions/Edit.cshtml | 20 ++++ .../Security/Views/Positions/Index.cshtml | 53 +++++++++++ .../Areas/Security/Views/Roles/Detail.cshtml | 17 ++++ .../Areas/Security/Views/Roles/Edit.cshtml | 20 ++++ .../Areas/Security/Views/Roles/Index.cshtml | 53 +++++++++++ .../Layout/Handlers/TextOnlyFieldHandler.cs | 10 +- .../Providers/NuGetDeployPackagesProvider.cs | 4 +- src/Server/DeploymentFramework/Web/Web.csproj | 10 ++ 25 files changed, 638 insertions(+), 8 deletions(-) create mode 100644 src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IPositionsRepository.cs create mode 100644 src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolesRepository.cs create mode 100644 src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Queries/PositionQueries.cs create mode 100644 src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Queries/RoleQueries.cs create mode 100644 src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs create mode 100644 src/Server/DeploymentFramework/Database/Security/RolesRepository.cs create mode 100644 src/Server/DeploymentFramework/Web/Areas/Security/Controllers/PositionsController.cs create mode 100644 src/Server/DeploymentFramework/Web/Areas/Security/Controllers/RolesController.cs create mode 100644 src/Server/DeploymentFramework/Web/Areas/Security/Models/Positions/IndexFilter.cs create mode 100644 src/Server/DeploymentFramework/Web/Areas/Security/Models/Roles/IndexFilter.cs create mode 100644 src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Detail.cshtml create mode 100644 src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Edit.cshtml create mode 100644 src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml create mode 100644 src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Detail.cshtml create mode 100644 src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Edit.cshtml create mode 100644 src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml diff --git a/src/Server/DeploymentFramework/BusinessLogic/BusinessLogic.csproj b/src/Server/DeploymentFramework/BusinessLogic/BusinessLogic.csproj index c2cc010..3cf427d 100644 --- a/src/Server/DeploymentFramework/BusinessLogic/BusinessLogic.csproj +++ b/src/Server/DeploymentFramework/BusinessLogic/BusinessLogic.csproj @@ -82,6 +82,8 @@ + + @@ -89,6 +91,8 @@ + + diff --git a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IPositionsRepository.cs b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IPositionsRepository.cs new file mode 100644 index 0000000..56d94ee --- /dev/null +++ b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IPositionsRepository.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Baud.Deployment.BusinessLogic.Domain.Security.Entities; + +namespace Baud.Deployment.BusinessLogic.Domain.Security.Contracts +{ + public interface IPositionsRepository + { + IQueryable GetPositions(); + + Position GetPositionDetail(short id); + + void UpdatePosition(short id, Position position); + } +} diff --git a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolesRepository.cs b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolesRepository.cs new file mode 100644 index 0000000..ac00e16 --- /dev/null +++ b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolesRepository.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Baud.Deployment.BusinessLogic.Domain.Security.Entities; + +namespace Baud.Deployment.BusinessLogic.Domain.Security.Contracts +{ + public interface IRolesRepository + { + IQueryable GetRoles(); + + Role GetRoleDetail(short id); + + void UpdateRole(short id, Role role); + } +} diff --git a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/ISecurityUow.cs b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/ISecurityUow.cs index 2327063..0e5fc1c 100644 --- a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/ISecurityUow.cs +++ b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/ISecurityUow.cs @@ -9,5 +9,9 @@ namespace Baud.Deployment.BusinessLogic.Domain.Security.Contracts public interface ISecurityUow : IUow { IUsersRepository Users { get; } + + IRolesRepository Roles { get; } + + IPositionsRepository Positions { get; } } } \ No newline at end of file diff --git a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Queries/PositionQueries.cs b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Queries/PositionQueries.cs new file mode 100644 index 0000000..9dae73d --- /dev/null +++ b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Queries/PositionQueries.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Baud.Deployment.BusinessLogic.Domain.Security.Entities; + +namespace Baud.Deployment.BusinessLogic.Domain.Security.Queries +{ + public static class PositionQueries + { + public static IQueryable FilterByID(this IQueryable query, int positionID) + { + return query.Where(x => x.ID == positionID); + } + + public static IQueryable OnlyActive(this IQueryable query) + { + return query.Where(x => !x.IsActive); + } + + public static IQueryable OnlyInactive(this IQueryable query) + { + return query.Where(x => x.IsActive); + } + } +} diff --git a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Queries/RoleQueries.cs b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Queries/RoleQueries.cs new file mode 100644 index 0000000..a8861e5 --- /dev/null +++ b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Queries/RoleQueries.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Baud.Deployment.BusinessLogic.Domain.Security.Entities; + +namespace Baud.Deployment.BusinessLogic.Domain.Security.Queries +{ + public static class RoleQueries + { + public static IQueryable FilterByID(this IQueryable query, int roleID) + { + return query.Where(x => x.ID == roleID); + } + + public static IQueryable OnlyActive(this IQueryable query) + { + return query.Where(x => !x.IsActive); + } + + public static IQueryable OnlyInactive(this IQueryable query) + { + return query.Where(x => x.IsActive); + } + } +} diff --git a/src/Server/DeploymentFramework/Database/Database.csproj b/src/Server/DeploymentFramework/Database/Database.csproj index 8d77614..b833da6 100644 --- a/src/Server/DeploymentFramework/Database/Database.csproj +++ b/src/Server/DeploymentFramework/Database/Database.csproj @@ -63,6 +63,8 @@ + + diff --git a/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs b/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs new file mode 100644 index 0000000..faa8383 --- /dev/null +++ b/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Baud.Deployment.BusinessLogic.Domain.Security.Contracts; +using Baud.Deployment.BusinessLogic.Domain.Security.Entities; +using Baud.Deployment.BusinessLogic.Domain.Security.Queries; + +namespace Baud.Deployment.Database.Security +{ + public class PositionsRepository : RepositoryBase, IPositionsRepository + { + public PositionsRepository(SecurityDbContext context) + : base(context) + { + } + + public IQueryable GetPositions() + { + return Context.Positions; + } + + public Position GetPositionDetail(short id) + { + return Context.Positions.FilterByID(id).FirstOrDefault(); + } + + public void UpdatePosition(short id, Position position) + { + position.ID = id; + + Context.AttachAsModified(position, + x => x.Name, + x => x.IsActive); + } + } +} diff --git a/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs b/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs new file mode 100644 index 0000000..fd3012a --- /dev/null +++ b/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Baud.Deployment.BusinessLogic.Domain.Security.Contracts; +using Baud.Deployment.BusinessLogic.Domain.Security.Entities; +using Baud.Deployment.BusinessLogic.Domain.Security.Queries; + +namespace Baud.Deployment.Database.Security +{ + public class RolesRepository : RepositoryBase, IRolesRepository + { + public RolesRepository(SecurityDbContext context) + : base(context) + { + } + + public IQueryable GetRoles() + { + return Context.Roles; + } + + public Role GetRoleDetail(short id) + { + return Context.Roles.FilterByID(id).FirstOrDefault(); + } + + public void UpdateRole(short id, Role role) + { + role.ID = id; + + Context.AttachAsModified(role, + x => x.Name, + x => x.IsActive); + } + } +} diff --git a/src/Server/DeploymentFramework/Database/Security/SecurityDbContext.cs b/src/Server/DeploymentFramework/Database/Security/SecurityDbContext.cs index c5a2838..d6a2c5f 100644 --- a/src/Server/DeploymentFramework/Database/Security/SecurityDbContext.cs +++ b/src/Server/DeploymentFramework/Database/Security/SecurityDbContext.cs @@ -16,6 +16,8 @@ public SecurityDbContext() } public IDbSet Users { get; set; } + public IDbSet Roles { get; set; } + public IDbSet Positions { get; set; } protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder) { diff --git a/src/Server/DeploymentFramework/Database/Security/SecurityUow.cs b/src/Server/DeploymentFramework/Database/Security/SecurityUow.cs index 4d19630..63689a6 100644 --- a/src/Server/DeploymentFramework/Database/Security/SecurityUow.cs +++ b/src/Server/DeploymentFramework/Database/Security/SecurityUow.cs @@ -16,6 +16,16 @@ public IUsersRepository Users get { return GetRepository(); } } + public IRolesRepository Roles + { + get { return GetRepository(); } + } + + public IPositionsRepository Positions + { + get { return GetRepository(); } + } + public SecurityUow(IDbContextProvider contextProvider, IRepositoryProvider repositoryProvider, ICurrentUserProvider currentUserProvider, IDateTimeProvider dateTimeProvider) : base(contextProvider, repositoryProvider, currentUserProvider, dateTimeProvider) { diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/PositionsController.cs b/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/PositionsController.cs new file mode 100644 index 0000000..df1f233 --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/PositionsController.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using Baud.Deployment.BusinessLogic.Domain.Security.Contracts; +using Baud.Deployment.Web.Areas.Security.Models.Positions; +using Baud.Deployment.Web.Framework.Web; + +namespace Baud.Deployment.Web.Areas.Security.Controllers +{ + public partial class PositionsController : Controller + { + private readonly Func _securityUow; + + public PositionsController(Func securityUow) + { + _securityUow = securityUow; + } + + public ActionResult Index(IndexFilter filter, PagingData paging) + { + paging.PageSize = 2; // only for testing + + ViewBag.Filter = filter; + + using (var uow = _securityUow()) + { + var positionsQuery = uow.Positions.GetPositions(); + positionsQuery = filter.Apply(positionsQuery); + var data = positionsQuery.ToPagedList(paging); + + return View(data); + } + } + + public virtual ActionResult Detail(short id) + { + using (var uow = _securityUow()) + { + var position = uow.Positions.GetPositionDetail(id); + + if (position == null) + { + return HttpNotFound(); + } + + return View(position); + } + } + + public virtual ActionResult Edit(short id) + { + using (var uow = _securityUow()) + { + var position = uow.Positions.GetPositionDetail(id); + + if (position == null) + { + return HttpNotFound(); + } + + return View(position); + } + } + // TODO: T4 template for Actions + [HttpPost] + [ValidateAntiForgeryToken] + public virtual ActionResult Edit(short id, FormCollection form) + { + using (var uow = _securityUow()) + { + var position = uow.Positions.GetPositionDetail(id); + + if (position == null) + { + return HttpNotFound(); + } + + if (!TryUpdateModel(position)) + { + return View(position); + } + + uow.Positions.UpdatePosition(id, position); + uow.Commit(); + + // TODO add confirmation toast message + return RedirectToAction(Actions.Detail(id)); + } + } + } +} \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/RolesController.cs b/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/RolesController.cs new file mode 100644 index 0000000..96cf2fb --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/RolesController.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using Baud.Deployment.BusinessLogic.Domain.Security.Contracts; +using Baud.Deployment.Web.Areas.Security.Models.Roles; +using Baud.Deployment.Web.Framework.Security; +using Baud.Deployment.Web.Framework.Web; + +namespace Baud.Deployment.Web.Areas.Security.Controllers +{ + public partial class RolesController : Controller + { + private readonly Func _securityUow; + + public RolesController(Func securityUow) + { + _securityUow = securityUow; + } + + public ActionResult Index(IndexFilter filter, PagingData paging) + { + paging.PageSize = 2; // only for testing + + ViewBag.Filter = filter; + + using (var uow = _securityUow()) + { + var rolesQuery = uow.Roles.GetRoles(); + rolesQuery = filter.Apply(rolesQuery); + var data = rolesQuery.ToPagedList(paging); + + return View(data); + } + } + + public virtual ActionResult Detail(short id) + { + using (var uow = _securityUow()) + { + var role = uow.Roles.GetRoleDetail(id); + + if (role == null) + { + return HttpNotFound(); + } + + return View(role); + } + } + + public virtual ActionResult Edit(short id) + { + using (var uow = _securityUow()) + { + var role = uow.Roles.GetRoleDetail(id); + + if (role == null) + { + return HttpNotFound(); + } + + return View(role); + } + } + // TODO: T4 template for Actions + [HttpPost] + [ValidateAntiForgeryToken] + public virtual ActionResult Edit(short id, FormCollection form) + { + using (var uow = _securityUow()) + { + var role = uow.Roles.GetRoleDetail(id); + + if (role == null) + { + return HttpNotFound(); + } + + if (!TryUpdateModel(role)) + { + return View(role); + } + + uow.Roles.UpdateRole(id, role); + uow.Commit(); + + // TODO add confirmation toast message + return RedirectToAction(Actions.Detail(id)); + } + } + } +} \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Models/Positions/IndexFilter.cs b/src/Server/DeploymentFramework/Web/Areas/Security/Models/Positions/IndexFilter.cs new file mode 100644 index 0000000..27ead02 --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Models/Positions/IndexFilter.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Baud.Deployment.BusinessLogic.Domain.Security.Entities; +using Baud.Deployment.BusinessLogic.Domain.Security.Queries; + +namespace Baud.Deployment.Web.Areas.Security.Models.Positions +{ + public class IndexFilter + { + public string Name { get; set; } + public bool? IsActive { get; set; } + + public IQueryable Apply(IQueryable source) + { + IQueryable query = source.OrderBy(x => x.Name); + + query = query.Filter(Name, x => x.Name.Contains(Name)); + + if (IsActive == true) + { + query = query.OnlyActive(); + } + else if (IsActive == false) + { + query = query.OnlyInactive(); + } + + return query; + } + } +} \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Models/Roles/IndexFilter.cs b/src/Server/DeploymentFramework/Web/Areas/Security/Models/Roles/IndexFilter.cs new file mode 100644 index 0000000..c218ab2 --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Models/Roles/IndexFilter.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Baud.Deployment.BusinessLogic.Domain.Security.Entities; +using Baud.Deployment.BusinessLogic.Domain.Security.Queries; + +namespace Baud.Deployment.Web.Areas.Security.Models.Roles +{ + public class IndexFilter + { + public string Name { get; set; } + public bool? IsActive { get; set; } + + public IQueryable Apply(IQueryable source) + { + IQueryable query = source.OrderBy(x => x.Name); + + query = query.Filter(Name, x => x.Name.Contains(Name)); + + if (IsActive == true) + { + query = query.OnlyActive(); + } + else if (IsActive == false) + { + query = query.OnlyInactive(); + } + + return query; + } + } +} \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Models/Users/IndexFilter.cs b/src/Server/DeploymentFramework/Web/Areas/Security/Models/Users/IndexFilter.cs index ab1264d..0d2b23f 100644 --- a/src/Server/DeploymentFramework/Web/Areas/Security/Models/Users/IndexFilter.cs +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Models/Users/IndexFilter.cs @@ -18,7 +18,6 @@ public IQueryable Apply(IQueryable source) query = query.Filter(Name, x => x.FirstName.Contains(Name) || x.LastName.Contains(Name)); - DateTime now = DateTime.Now; if (IsActive == true) { query = query.OnlyActive(); diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Detail.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Detail.cshtml new file mode 100644 index 0000000..8d72b17 --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Detail.cshtml @@ -0,0 +1,17 @@ +@model Baud.Deployment.BusinessLogic.Domain.Security.Entities.Position +@{ + ViewBag.Title = "Position detail"; +} + +

@ViewBag.Title

+ +@using (var f = Html.BeginReadOnlyForm()) +{ + using (var s = f.BeginSection()) + { + @s.FieldFor(m => m.Name) + @s.FieldFor(m => m.IsActive) + } +} + +@Html.GuardedActionLink("Edit", MVC.Security.Positions.Edit(Model.ID), new SimpleHtmlAttributes("class", "btn btn-default")) \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Edit.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Edit.cshtml new file mode 100644 index 0000000..7e3bb28 --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Edit.cshtml @@ -0,0 +1,20 @@ +@model Baud.Deployment.BusinessLogic.Domain.Security.Entities.Position +@{ + ViewBag.Title = "Position detail"; +} + +

@ViewBag.Title

+ +@using (var f = Html.BeginCustomForm()) +{ + using (var s = f.BeginSection()) + { + @s.FieldFor(m => m.Name) + @s.FieldFor(m => m.IsActive) + } + + using (var n = f.BeginNavigation()) + { + @n.Submit("Save") + } +} \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml new file mode 100644 index 0000000..a231ef3 --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml @@ -0,0 +1,53 @@ +@model PagedList.PagedList +@using PagedList.Mvc +@{ + var filter = (Baud.Deployment.Web.Areas.Security.Models.Positions.IndexFilter)ViewBag.Filter; + ViewBag.Title = "Positions"; +} + +

@ViewBag.Title

+ +
+ @using (var f = Html.BeginCustomForm(method: FormMethod.Get)) + { + using (var s = f.BeginSection("Filter")) + { + @s.FieldFor(m => filter.Name) + @s.FieldFor(m => filter.IsActive) + } + + using (var s = f.BeginNavigation()) + { + @s.Submit("Filter") + } + } +
+ +@if (Model.Any()) +{ + + + + + + + + + + @foreach (var position in Model) + { + + + + + + } + +
@Html.SortingLink(m => m[0].Name)@Html.SortingLink(m => m[0].IsActive)
@position.Name@position.IsActive@Html.GuardedActionLink("Detail", MVC.Security.Positions.Detail(position.ID))
+ + @Html.PagedListPager(Model, page => Url.CurrentWithPageNumber(page), PagedListRenderOptions.OnlyShowFivePagesAtATime) +} +else +{ +

No data

+} \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Detail.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Detail.cshtml new file mode 100644 index 0000000..bfeac30 --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Detail.cshtml @@ -0,0 +1,17 @@ +@model Baud.Deployment.BusinessLogic.Domain.Security.Entities.Role +@{ + ViewBag.Title = "Role detail"; +} + +

@ViewBag.Title

+ +@using (var f = Html.BeginReadOnlyForm()) +{ + using (var s = f.BeginSection()) + { + @s.FieldFor(m => m.Name) + @s.FieldFor(m => m.IsActive) + } +} + +@Html.GuardedActionLink("Edit", MVC.Security.Roles.Edit(Model.ID), new SimpleHtmlAttributes("class", "btn btn-default")) \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Edit.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Edit.cshtml new file mode 100644 index 0000000..60ffa33 --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Edit.cshtml @@ -0,0 +1,20 @@ +@model Baud.Deployment.BusinessLogic.Domain.Security.Entities.Role +@{ + ViewBag.Title = "Role detail"; +} + +

@ViewBag.Title

+ +@using (var f = Html.BeginCustomForm()) +{ + using (var s = f.BeginSection()) + { + @s.FieldFor(m => m.Name) + @s.FieldFor(m => m.IsActive) + } + + using (var n = f.BeginNavigation()) + { + @n.Submit("Save") + } +} \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml new file mode 100644 index 0000000..ce5010d --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml @@ -0,0 +1,53 @@ +@model PagedList.PagedList +@using PagedList.Mvc +@{ + var filter = (Baud.Deployment.Web.Areas.Security.Models.Roles.IndexFilter)ViewBag.Filter; + ViewBag.Title = "Roles"; +} + +

@ViewBag.Title

+ +
+ @using (var f = Html.BeginCustomForm(method: FormMethod.Get)) + { + using (var s = f.BeginSection("Filter")) + { + @s.FieldFor(m => filter.Name) + @s.FieldFor(m => filter.IsActive) + } + + using (var s = f.BeginNavigation()) + { + @s.Submit("Filter") + } + } +
+ +@if (Model.Any()) +{ + + + + + + + + + + @foreach (var role in Model) + { + + + + + + } + +
@Html.SortingLink(m => m[0].Name)@Html.SortingLink(m => m[0].IsActive)
@role.Name@role.IsActive@Html.GuardedActionLink("Detail", MVC.Security.Roles.Detail(role.ID))
+ + @Html.PagedListPager(Model, page => Url.CurrentWithPageNumber(page), PagedListRenderOptions.OnlyShowFivePagesAtATime) +} +else +{ +

No data

+} \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Framework/Web/Layout/Handlers/TextOnlyFieldHandler.cs b/src/Server/DeploymentFramework/Web/Framework/Web/Layout/Handlers/TextOnlyFieldHandler.cs index 56febfc..fea69e8 100644 --- a/src/Server/DeploymentFramework/Web/Framework/Web/Layout/Handlers/TextOnlyFieldHandler.cs +++ b/src/Server/DeploymentFramework/Web/Framework/Web/Layout/Handlers/TextOnlyFieldHandler.cs @@ -18,10 +18,10 @@ public TextOnlyFieldHandler(IFieldGenerator fieldGenerator) { } - //public override IHtmlString GenerateFieldHtml(ChameleonForms.Component.Config.IReadonlyFieldConfiguration fieldConfiguration) - //{ - // var text = base.GenerateFieldHtml(fieldConfiguration); - // return Original.OriginalDetailFormTemplateHelpers.FieldContent(text); - //} + ////public override IHtmlString GenerateFieldHtml(ChameleonForms.Component.Config.IReadonlyFieldConfiguration fieldConfiguration) + ////{ + //// var text = base.GenerateFieldHtml(fieldConfiguration); + //// return Original.OriginalDetailFormTemplateHelpers.FieldContent(text); + ////} } } \ No newline at end of file diff --git a/src/Server/DeploymentFramework/Web/Providers/NuGetDeployPackagesProvider.cs b/src/Server/DeploymentFramework/Web/Providers/NuGetDeployPackagesProvider.cs index 5ddc038..f6a2810 100644 --- a/src/Server/DeploymentFramework/Web/Providers/NuGetDeployPackagesProvider.cs +++ b/src/Server/DeploymentFramework/Web/Providers/NuGetDeployPackagesProvider.cs @@ -72,9 +72,9 @@ public byte[] GetPackageBytes(string packageFullPath) return File.ReadAllBytes(packageFullPath); } - // TODO get package file name + //// TODO get package file name - // TODO list available updates + //// TODO list available updates private IPackageRepository GetRepository() { diff --git a/src/Server/DeploymentFramework/Web/Web.csproj b/src/Server/DeploymentFramework/Web/Web.csproj index 67c16c8..1de59c7 100644 --- a/src/Server/DeploymentFramework/Web/Web.csproj +++ b/src/Server/DeploymentFramework/Web/Web.csproj @@ -303,7 +303,11 @@ + + + + @@ -405,6 +409,12 @@ + + + + + +