Skip to content

Commit

Permalink
Merge branch 'Berzeger-security-ui' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gius committed Jul 17, 2015
2 parents 827fff8 + b5c5058 commit b553a51
Show file tree
Hide file tree
Showing 34 changed files with 534 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,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
Expand Up @@ -17,6 +17,8 @@ public interface IPositionsRepository

void Disable(short id);

void UpdateName(short id, string name);
void UpdateName(short id);

void AddPosition(Position position);
}
}
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 @@ -17,6 +17,8 @@ public interface IRolesRepository

void Disable(short id);

void UpdateName(short id, string name);
void UpdateName(short id);

void AddRole(Role role);
}
}
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
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ public interface IUsersRepository
User GetUserDetail(short id);

void UpdateUser(short id, User user);

void AddUser(User user);
}
}
2 changes: 2 additions & 0 deletions src/Server/DeploymentFramework/Database/Database.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,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 All @@ -44,13 +51,17 @@ public void Disable(short id)
x => x.IsActive);
}

public void UpdateName(short id, string name)
public void UpdateName(short id)
{
Position position = GetPositionDetail(id);
position.Name = name;

Context.AttachAsModified(position,
x => x.Name);
}

public void AddPosition(Position position)
{
Context.Positions.Add(position);
}
}
}
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 All @@ -44,13 +49,17 @@ public void Disable(short id)
x => x.IsActive);
}

public void UpdateName(short id, string name)
public void UpdateName(short id)
{
Role role = GetRoleDetail(id);
role.Name = name;

Context.AttachAsModified(role,
x => x.Name);
}

public void AddRole(Role role)
{
Context.Roles.Add(role);
}
}
}
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 All @@ -38,5 +43,10 @@ public void UpdateUser(short id, User user)
x => x.ActiveFrom,
x => x.ActiveTo);
}

public void AddUser(User user)
{
Context.Users.Add(user);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@
<data name="BackToDetail" xml:space="preserve">
<value>Zpět na detail</value>
</data>
<data name="AddNewPosition" xml:space="preserve">
<value>Přidat novou pozici</value>
</data>
<data name="AddNewRole" xml:space="preserve">
<value>Přidat novou roli</value>
</data>
<data name="AddNewUser" xml:space="preserve">
<value>Přidat nového uživatele</value>
</data>
<data name="BackToList" xml:space="preserve">
<value>Zpět na seznam</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions src/Server/DeploymentFramework/Resources/StringResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@
<data name="BackToDetail" xml:space="preserve">
<value>Back to detail</value>
</data>
<data name="AddNewPosition" xml:space="preserve">
<value>Add new position</value>
</data>
<data name="AddNewRole" xml:space="preserve">
<value>Add new role</value>
</data>
<data name="AddNewUser" xml:space="preserve">
<value>Add new user</value>
</data>
<data name="BackToList" xml:space="preserve">
<value>Back to list</value>
</data>
Expand Down
Loading

0 comments on commit b553a51

Please sign in to comment.