Skip to content

Commit

Permalink
Positions, Roles and Users now display their links in Details. Relate…
Browse files Browse the repository at this point in the history
  • Loading branch information
Berzeger committed Jul 17, 2015
1 parent d5772f0 commit d4c3f50
Show file tree
Hide file tree
Showing 18 changed files with 203 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@
<Compile Include="Domain\EntityBase.cs" />
<Compile Include="Domain\IUow.cs" />
<Compile Include="Domain\Security\Contracts\IPositionsRepository.cs" />
<Compile Include="Domain\Security\Contracts\IRolePositionLinkRepository.cs" />
<Compile Include="Domain\Security\Contracts\IRolesRepository.cs" />
<Compile Include="Domain\Security\Contracts\ISecurityUow.cs" />
<Compile Include="Domain\Security\Contracts\IUserPositionLinkRepository.cs" />
<Compile Include="Domain\Security\Contracts\IUsersRepository.cs" />
<Compile Include="Domain\Security\Entities\Position.cs" />
<Compile Include="Domain\Security\Entities\Role.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ public interface ISecurityUow : IUow
IRolesRepository Roles { get; }

IPositionsRepository Positions { get; }

IRolePositionLinkRepository RolePositionLinks { get; }

IUserPositionLinkRepository UserPositionLinks { get; }
}
}
Original file line number Diff line number Diff line change
@@ -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
{
}
}
2 changes: 2 additions & 0 deletions src/Server/DeploymentFramework/Database/Database.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@
<Compile Include="RepositoryBase.cs" />
<Compile Include="RepositoryProviderBase.cs" />
<Compile Include="Security\PositionsRepository.cs" />
<Compile Include="Security\RolePositionLinkRepository.cs" />
<Compile Include="Security\RolesRepository.cs" />
<Compile Include="Security\SecurityDbContext.cs" />
<Compile Include="Security\SecurityUow.cs" />
<Compile Include="Security\UserPositionLinkRepository.cs" />
<Compile Include="Security\UsersRepository.cs" />
<Compile Include="UowBase.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Data.Entity;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -23,7 +24,13 @@ public IQueryable<Position> 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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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<SecurityDbContext>, IRolePositionLinkRepository
{
public RolePositionLinkRepository(SecurityDbContext context)
: base(context)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Data.Entity;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -23,7 +24,11 @@ public IQueryable<Role> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public SecurityDbContext()
public IDbSet<User> Users { get; set; }
public IDbSet<Role> Roles { get; set; }
public IDbSet<Position> Positions { get; set; }
public IDbSet<RolePositionLink> RolePositionLinks { get; set; }
public IDbSet<UserPositionLink> UserPositionLinks { get; set; }

protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
{
Expand Down
10 changes: 10 additions & 0 deletions src/Server/DeploymentFramework/Database/Security/SecurityUow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ public IPositionsRepository Positions
get { return GetRepository<IPositionsRepository>(); }
}

public IRolePositionLinkRepository RolePositionLinks
{
get { return GetRepository<IRolePositionLinkRepository>(); }
}

public IUserPositionLinkRepository UserPositionLinks
{
get { return GetRepository<IUserPositionLinkRepository>(); }
}

public SecurityUow(IDbContextProvider<SecurityDbContext> contextProvider, IRepositoryProvider<SecurityDbContext> repositoryProvider, ICurrentUserProvider currentUserProvider, IDateTimeProvider dateTimeProvider)
: base(contextProvider, repositoryProvider, currentUserProvider, dateTimeProvider)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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<SecurityDbContext>, IUserPositionLinkRepository
{
public UserPositionLinkRepository(SecurityDbContext context)
: base(context)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Data.Entity;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -23,7 +24,11 @@ public IQueryable<User> 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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@model Baud.Deployment.BusinessLogic.Domain.Security.Entities.Position
@using Baud.Deployment.Resources

@{
ViewBag.Title = StringResources.PositionDetail;
}

<h2>@ViewBag.Title</h2>

@using (var f = Html.BeginReadOnlyForm())
{
using (var s = f.BeginSection())
{
@s.FieldFor(m => m.Name)
@s.FieldFor(m => m.IsActive)

<div class="row">
<div class="col-md-6">
<div class="well">
<h3>@StringResources.Users</h3>
<div class="form-group">
@foreach (var user in Model.UserLinks)
{
@s.FieldFor(m => user.User.Login).Label("")
}
</div>
</div>
</div>
<div class="col-md-6">
<div class="well">
<h3>@StringResources.Roles</h3>
<div class="form-group">
@foreach (var role in Model.RoleLinks)
{
@s.FieldFor(m => role.Role.Name).Label("")
}
</div>
</div>
</div>
</div>


}
}

@Html.GuardedActionLink(StringResources.BackToList, MVC.Security.Positions.Index(), new SimpleHtmlAttributes("class", "btn btn-default"))
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<th>@Html.SortingLink(m => m[0].IsActive)</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
Expand All @@ -52,6 +53,7 @@
{
<td>@Html.GuardedActionLink(StringResources.Enable, MVC.Security.Positions.Enable(position.ID))</td>
}
<td>@Html.GuardedActionLink(StringResources.Detail, MVC.Security.Positions.Detail(position.ID))</td>
</tr>
}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@model Baud.Deployment.BusinessLogic.Domain.Security.Entities.Role
@using Baud.Deployment.Resources

@{
ViewBag.Title = StringResources.RoleDetail;
}

<h2>@ViewBag.Title</h2>

@using (var f = Html.BeginReadOnlyForm())
{
using (var s = f.BeginSection())
{
@s.FieldFor(m => m.Name)
@s.FieldFor(m => m.IsActive)

<div class="row">
<div class="col-md-12">
<div class="well">
<h3>@StringResources.Positions</h3>
<div class="form-group">
@foreach (var position in Model.PositionLinks)
{
@s.FieldFor(m => position.Position.Name).Label("")
}
</div>
</div>
</div>
</div>


}
}

@Html.GuardedActionLink(StringResources.BackToList, MVC.Security.Roles.Index(), new SimpleHtmlAttributes("class", "btn btn-default"))


Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<th>@Html.SortingLink(m => m[0].IsActive)</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
Expand All @@ -52,6 +53,7 @@
{
<td>@Html.GuardedActionLink(StringResources.Enable, MVC.Security.Roles.Enable(role.ID))</td>
}
<td>@Html.GuardedActionLink(StringResources.Detail, MVC.Security.Roles.Detail(role.ID))</td>
</tr>
}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
@s.FieldFor(m => m.ActiveFrom)
@s.FieldFor(m => m.ActiveTo)
@s.FieldFor(m => m.Note)

<div class="row">
<div class="col-md-12">
<div class="well">
<h3>@StringResources.Positions</h3>
<div class="form-group">
@foreach (var position in Model.PositionLinks)
{
@s.FieldFor(m => position.Position.Name).Label("")
}
</div>
</div>
</div>
</div>


}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Server/DeploymentFramework/Web/Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@
<Content Include="Areas\Security\Views\Users\Add.cshtml" />
<Content Include="Areas\Security\Views\Positions\Add.cshtml" />
<Content Include="Areas\Security\Views\Roles\Add.cshtml" />
<Content Include="Areas\Security\Views\Positions\Detail.cshtml" />
<Content Include="Areas\Security\Views\Roles\Detail.cshtml" />
<None Include="T4MVC.tt.settings.xml" />
<Content Include="Web.config" />
<Content Include="Web.Debug.config">
Expand Down

0 comments on commit d4c3f50

Please sign in to comment.