Beispiel #1
0
 public void Create(RolePermissionRepository rolePermissionRepository)
 {
     Models.RolePermission newRolePermission = new Models.RolePermission();
     newRolePermission.Permissionid = rolePermissionRepository.Permissionid;
     newRolePermission.Roleid       = rolePermissionRepository.Roleid;
     this.save(newRolePermission);
 }
Beispiel #2
0
 private void save(Models.RolePermission RolePermission, bool isUpdate = false)
 {
     if (!isUpdate)
     {
         this.context.RolePermissions.Add(RolePermission);
     }
     this.context.SaveChanges();
 }
Beispiel #3
0
        public void Update(long id, RolePermissionRepository rolePermissionRepository)
        {
            Models.RolePermission oldRolePermission = this.rolePermissionQueryRepository.Find(id);
            if (oldRolePermission == null)
            {
                return;
            }

            oldRolePermission.Permissionid = rolePermissionRepository.Permissionid;
            oldRolePermission.Roleid       = rolePermissionRepository.Roleid;
            this.save(oldRolePermission, true);
        }
Beispiel #4
0
        public RolePermissionRepository FindById(long id = 0)
        {
            Models.RolePermission rolePermission = this.Find(id);
            if (rolePermission == null)
            {
                return(new RolePermissionRepository());
            }

            this.rolePermissionRepository.Id           = rolePermission.Id;
            this.rolePermissionRepository.Permissionid = rolePermission.Permissionid;
            this.rolePermissionRepository.Roleid       = rolePermission.Roleid;
            this.rolePermissionRepository.MapToRoleRepo(rolePermission.Role);
            this.rolePermissionRepository.MapToPermissionRepo(rolePermission.Permission);

            return(this.rolePermissionRepository);
        }
Beispiel #5
0
        public RolePermissionRepository FindByRoleAndPermission(long roleid, long permission)
        {
            Models.RolePermission rolePermission = this.context.RolePermissions
                                                   .Where(rolePermission => rolePermission.Roleid == roleid && rolePermission.Permissionid == permission)
                                                   .FirstOrDefault();

            if (rolePermission == null)
            {
                return(new RolePermissionRepository());
            }

            this.rolePermissionRepository.Id           = rolePermission.Id;
            this.rolePermissionRepository.Permissionid = rolePermission.Permissionid;
            this.rolePermissionRepository.Roleid       = rolePermission.Roleid;

            return(this.rolePermissionRepository);
        }
Beispiel #6
0
 public void Delete(long id)
 {
     Models.RolePermission rolePermission = this.context.RolePermissions.Where(rolePermission => rolePermission.Id == id).FirstOrDefault();
     this.context.RolePermissions.Remove(rolePermission);
     this.context.SaveChanges();
 }