private void CreateRolePermission(Role role, int permissionId) { RolePermission rolePermission = new RolePermission(); rolePermission.RoleId = role.Id; rolePermission.PermissionId = permissionId; this.Storage.GetRepository<IRolePermissionRepository>().Create(rolePermission); }
public RoleViewModel Build(Role role) { return new RoleViewModel() { Id = role.Id, Name = role.Name, Position = role.Position }; }
public Role Map(CreateOrEditViewModel createOrEdit) { Role role = new Role(); if (createOrEdit.Id != null) role = this.handler.Storage.GetRepository<IRoleRepository>().WithKey((int)createOrEdit.Id); role.Code = createOrEdit.Code; role.Name = createOrEdit.Name; role.Position = createOrEdit.Position; return role; }
public UserRoleViewModel Build(User user, Role role) { UserRole userRole = null; if (user != null) userRole = this.handler.Storage.GetRepository<IUserRoleRepository>().WithKey(user.Id, role.Id); return new UserRoleViewModel() { Role = new RoleViewModelBuilder(this.handler).Build(role), IsAssigned = userRole != null }; }
public RolePermissionViewModel Build(Role role, Permission permission) { RolePermission rolePermission = null; if (role != null) rolePermission = this.handler.Storage.GetRepository<IRolePermissionRepository>().WithKey(role.Id, permission.Id); return new RolePermissionViewModel() { Permission = new PermissionViewModelBuilder(this.handler).Build(permission), IsAssigned = rolePermission != null }; }
private void CreateRolePermissions(Role role) { foreach (string key in this.Request.Form.Keys) { if (key.StartsWith("permission") && this.Request.Form[key] == true.ToString().ToLower()) { string permissionId = key.Replace("permission", string.Empty); this.CreateRolePermission(role, int.Parse(permissionId)); } } this.Storage.Save(); }
private void CreateOrEditRolePermissions(Role role) { this.DeleteRolePermissions(role); this.CreateRolePermissions(role); }
private void DeleteRolePermissions(Role role) { foreach (RolePermission rolePermission in this.Storage.GetRepository<IRolePermissionRepository>().FilteredByRoleId(role.Id)) this.Storage.GetRepository<IRolePermissionRepository>().Delete(rolePermission); this.Storage.Save(); }
public IEnumerable<RolePermissionViewModel> GetRolePermissions(Role role = null) { return this.handler.Storage.GetRepository<IPermissionRepository>().All().Select( p => new RolePermissionViewModelBuilder(this.handler).Build(role, p) ); }