diff --git a/src/Server/DeploymentFramework/BusinessLogic/BusinessLogic.csproj b/src/Server/DeploymentFramework/BusinessLogic/BusinessLogic.csproj index ae60d10..e1b5d29 100644 --- a/src/Server/DeploymentFramework/BusinessLogic/BusinessLogic.csproj +++ b/src/Server/DeploymentFramework/BusinessLogic/BusinessLogic.csproj @@ -83,8 +83,10 @@ + + diff --git a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolePositionLinkRepository.cs b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolePositionLinkRepository.cs new file mode 100644 index 0000000..59d6b99 --- /dev/null +++ b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolePositionLinkRepository.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Baud.Deployment.BusinessLogic.Domain.Security.Contracts +{ + public interface IRolePositionLinkRepository + { + } +} diff --git a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/ISecurityUow.cs b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/ISecurityUow.cs index 0e5fc1c..d398a49 100644 --- a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/ISecurityUow.cs +++ b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/ISecurityUow.cs @@ -13,5 +13,9 @@ public interface ISecurityUow : IUow IRolesRepository Roles { get; } IPositionsRepository Positions { get; } + + IRolePositionLinkRepository RolePositionLinks { get; } + + IUserPositionLinkRepository UserPositionLinks { get; } } } \ No newline at end of file diff --git a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IUserPositionLinkRepository.cs b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IUserPositionLinkRepository.cs new file mode 100644 index 0000000..9d31f7d --- /dev/null +++ b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IUserPositionLinkRepository.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Baud.Deployment.BusinessLogic.Domain.Security.Contracts +{ + public interface IUserPositionLinkRepository + { + } +} diff --git a/src/Server/DeploymentFramework/Database/Database.csproj b/src/Server/DeploymentFramework/Database/Database.csproj index b833da6..393d938 100644 --- a/src/Server/DeploymentFramework/Database/Database.csproj +++ b/src/Server/DeploymentFramework/Database/Database.csproj @@ -64,9 +64,11 @@ + + diff --git a/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs b/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs index 0ba6f30..98fc3a5 100644 --- a/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs +++ b/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Data.Entity; using System.Collections.Generic; using System.Linq; using System.Text; @@ -23,7 +24,13 @@ public IQueryable GetPositions() public Position GetPositionDetail(short id) { - return Context.Positions.FilterByID(id).FirstOrDefault(); + return Context.Positions + .FilterByID(id) + .Include(x => x.RoleLinks) + .Include("RoleLinks.Role") + .Include(x => x.UserLinks) + .Include("UserLinks.User") + .FirstOrDefault(); } public void Enable(short id) diff --git a/src/Server/DeploymentFramework/Database/Security/RolePositionLinkRepository.cs b/src/Server/DeploymentFramework/Database/Security/RolePositionLinkRepository.cs new file mode 100644 index 0000000..62234a0 --- /dev/null +++ b/src/Server/DeploymentFramework/Database/Security/RolePositionLinkRepository.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Baud.Deployment.BusinessLogic.Domain.Security.Contracts; + +namespace Baud.Deployment.Database.Security +{ + public class RolePositionLinkRepository : RepositoryBase, IRolePositionLinkRepository + { + public RolePositionLinkRepository(SecurityDbContext context) + : base(context) + { + } + } +} diff --git a/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs b/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs index 896a748..9f8457a 100644 --- a/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs +++ b/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Data.Entity; using System.Collections.Generic; using System.Linq; using System.Text; @@ -23,7 +24,11 @@ public IQueryable GetRoles() public Role GetRoleDetail(short id) { - return Context.Roles.FilterByID(id).FirstOrDefault(); + return Context.Roles + .FilterByID(id) + .Include(x => x.PositionLinks) + .Include("PositionLinks.Position") + .FirstOrDefault(); } public void Enable(short id) diff --git a/src/Server/DeploymentFramework/Database/Security/SecurityDbContext.cs b/src/Server/DeploymentFramework/Database/Security/SecurityDbContext.cs index d6a2c5f..ef6f261 100644 --- a/src/Server/DeploymentFramework/Database/Security/SecurityDbContext.cs +++ b/src/Server/DeploymentFramework/Database/Security/SecurityDbContext.cs @@ -18,6 +18,8 @@ public SecurityDbContext() public IDbSet Users { get; set; } public IDbSet Roles { get; set; } public IDbSet Positions { get; set; } + public IDbSet RolePositionLinks { get; set; } + public IDbSet UserPositionLinks { 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 63689a6..6f4bc39 100644 --- a/src/Server/DeploymentFramework/Database/Security/SecurityUow.cs +++ b/src/Server/DeploymentFramework/Database/Security/SecurityUow.cs @@ -26,6 +26,16 @@ public IPositionsRepository Positions get { return GetRepository(); } } + public IRolePositionLinkRepository RolePositionLinks + { + get { return GetRepository(); } + } + + public IUserPositionLinkRepository UserPositionLinks + { + get { return GetRepository(); } + } + public SecurityUow(IDbContextProvider contextProvider, IRepositoryProvider repositoryProvider, ICurrentUserProvider currentUserProvider, IDateTimeProvider dateTimeProvider) : base(contextProvider, repositoryProvider, currentUserProvider, dateTimeProvider) { diff --git a/src/Server/DeploymentFramework/Database/Security/UserPositionLinkRepository.cs b/src/Server/DeploymentFramework/Database/Security/UserPositionLinkRepository.cs new file mode 100644 index 0000000..ff07fce --- /dev/null +++ b/src/Server/DeploymentFramework/Database/Security/UserPositionLinkRepository.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Baud.Deployment.BusinessLogic.Domain.Security.Contracts; + +namespace Baud.Deployment.Database.Security +{ + public class UserPositionLinkRepository : RepositoryBase, IUserPositionLinkRepository + { + public UserPositionLinkRepository(SecurityDbContext context) + : base(context) + { + } + } +} diff --git a/src/Server/DeploymentFramework/Database/Security/UsersRepository.cs b/src/Server/DeploymentFramework/Database/Security/UsersRepository.cs index 571ef0e..e176aee 100644 --- a/src/Server/DeploymentFramework/Database/Security/UsersRepository.cs +++ b/src/Server/DeploymentFramework/Database/Security/UsersRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Data.Entity; using System.Collections.Generic; using System.Linq; using System.Text; @@ -23,7 +24,11 @@ public IQueryable GetUsers() public User GetUserDetail(short id) { - return Context.Users.FilterByID(id).FirstOrDefault(); + return Context.Users + .FilterByID(id) + .Include(x => x.PositionLinks) + .Include("PositionLinks.Position") + .FirstOrDefault(); } public void UpdateUser(short id, User user) 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..20903d8 --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Detail.cshtml @@ -0,0 +1,46 @@ +@model Baud.Deployment.BusinessLogic.Domain.Security.Entities.Position +@using Baud.Deployment.Resources + +@{ + ViewBag.Title = StringResources.PositionDetail; +} + +@ViewBag.Title + +@using (var f = Html.BeginReadOnlyForm()) +{ + using (var s = f.BeginSection()) + { + @s.FieldFor(m => m.Name) + @s.FieldFor(m => m.IsActive) + + + + + @StringResources.Users + + @foreach (var user in Model.UserLinks) + { + @s.FieldFor(m => user.User.Login).Label("") + } + + + + + + @StringResources.Roles + + @foreach (var role in Model.RoleLinks) + { + @s.FieldFor(m => role.Role.Name).Label("") + } + + + + + + + } +} + +@Html.GuardedActionLink(StringResources.BackToList, MVC.Security.Positions.Index(), new SimpleHtmlAttributes("class", "btn btn-default")) diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml index 77985e4..b4d056e 100644 --- a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml @@ -35,6 +35,7 @@ @Html.SortingLink(m => m[0].IsActive) + @@ -52,6 +53,7 @@ { @Html.GuardedActionLink(StringResources.Enable, MVC.Security.Positions.Enable(position.ID)) } + @Html.GuardedActionLink(StringResources.Detail, MVC.Security.Positions.Detail(position.ID)) } 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..6c0d79d --- /dev/null +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Detail.cshtml @@ -0,0 +1,37 @@ +@model Baud.Deployment.BusinessLogic.Domain.Security.Entities.Role +@using Baud.Deployment.Resources + +@{ + ViewBag.Title = StringResources.RoleDetail; +} + +@ViewBag.Title + +@using (var f = Html.BeginReadOnlyForm()) +{ + using (var s = f.BeginSection()) + { + @s.FieldFor(m => m.Name) + @s.FieldFor(m => m.IsActive) + + + + + @StringResources.Positions + + @foreach (var position in Model.PositionLinks) + { + @s.FieldFor(m => position.Position.Name).Label("") + } + + + + + + + } +} + +@Html.GuardedActionLink(StringResources.BackToList, MVC.Security.Roles.Index(), new SimpleHtmlAttributes("class", "btn btn-default")) + + diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml index cc725c1..e2affe3 100644 --- a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml @@ -35,6 +35,7 @@ @Html.SortingLink(m => m[0].IsActive) + @@ -52,6 +53,7 @@ { @Html.GuardedActionLink(StringResources.Enable, MVC.Security.Roles.Enable(role.ID)) } + @Html.GuardedActionLink(StringResources.Detail, MVC.Security.Roles.Detail(role.ID)) } diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Users/Detail.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Users/Detail.cshtml index 2e24cb1..fbb29d0 100644 --- a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Users/Detail.cshtml +++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Users/Detail.cshtml @@ -18,6 +18,22 @@ @s.FieldFor(m => m.ActiveFrom) @s.FieldFor(m => m.ActiveTo) @s.FieldFor(m => m.Note) + + + + + @StringResources.Positions + + @foreach (var position in Model.PositionLinks) + { + @s.FieldFor(m => position.Position.Name).Label("") + } + + + + + + } } diff --git a/src/Server/DeploymentFramework/Web/Web.csproj b/src/Server/DeploymentFramework/Web/Web.csproj index e3df9fd..5c3fc14 100644 --- a/src/Server/DeploymentFramework/Web/Web.csproj +++ b/src/Server/DeploymentFramework/Web/Web.csproj @@ -432,6 +432,8 @@ + +