Exemplo n.º 1
0
        public static Role ToCoreModel(this dataModel.RoleEntity source, IPermissionScopeService scopeService)
        {
            var result = new Role();

            result.InjectFrom(source);

            result.Permissions = source.RolePermissions.Select(rp => rp.ToCoreModel(scopeService)).ToArray();
            return(result);
        }
Exemplo n.º 2
0
        public static void Patch(this dataModel.RoleEntity source, dataModel.RoleEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            var patchInjection = new PatchInjection <dataModel.RoleEntity>(x => x.Name, x => x.Description);

            target.InjectFrom(patchInjection, source);

            if (!source.RolePermissions.IsNullCollection())
            {
                var comparer = AnonymousComparer.Create((dataModel.RolePermissionEntity rp) => rp.PermissionId);
                source.RolePermissions.Patch(target.RolePermissions, comparer, (sourceItem, targetItem) => sourceItem.Patch(targetItem));
            }
        }
Exemplo n.º 3
0
        public static dataModel.RoleEntity ToDataModel(this Role source)
        {
            var result = new dataModel.RoleEntity
            {
                Name = source.Name,
                Description = source.Description,
            };

            if (source.Id != null)
                result.Id = source.Id;

            result.RolePermissions = new NullCollection<dataModel.RolePermissionEntity>();

            if (source.Permissions != null)
            {
                result.RolePermissions = new ObservableCollection<dataModel.RolePermissionEntity>(source.Permissions.Select(x=> x.ToRolePemissionDataModel()));
            }
            return result;
        }
        public static RoleEntity ToDataModel(this Role source)
        {
            var result = new RoleEntity
            {
                Name = source.Name,
                Description = source.Description,
            };

            if (source.Id != null)
                result.Id = source.Id;

            result.RolePermissions = new NullCollection<RolePermissionEntity>();

            if (source.Permissions != null)
            {
                result.RolePermissions = new ObservableCollection<RolePermissionEntity>(source.Permissions.Select(p => new RolePermissionEntity { PermissionId = p.Id }));
            }

            return result;
        }
Exemplo n.º 5
0
        public static dataModel.RoleEntity ToDataModel(this Role source)
        {
            var result = new dataModel.RoleEntity
            {
                Name        = source.Name,
                Description = source.Description,
            };

            if (source.Id != null)
            {
                result.Id = source.Id;
            }

            result.RolePermissions = new NullCollection <dataModel.RolePermissionEntity>();

            if (source.Permissions != null)
            {
                result.RolePermissions = new ObservableCollection <dataModel.RolePermissionEntity>(source.Permissions.Select(x => x.ToRolePemissionDataModel()));
            }
            return(result);
        }
        public static void Patch(this RoleEntity source, RoleEntity target)
        {
            if (target == null)
                throw new ArgumentNullException("target");

            var patchInjection = new PatchInjection<RoleEntity>(x => x.Name, x => x.Description);
            target.InjectFrom(patchInjection, source);

            if (!source.RolePermissions.IsNullCollection())
            {
                var comparer = AnonymousComparer.Create((RolePermissionEntity rp) => rp.PermissionId);
                source.RolePermissions.Patch(target.RolePermissions, comparer, (sourceItem, targetItem) => { });
            }
        }