Ejemplo n.º 1
0
        public GenericResult CheckParentPermission(List <PermissionViewModel> permissionViewModels)
        {
            foreach (var permission in permissionViewModels)
            {
                var function = _functionRepository.FindSingle(x => x.Id == permission.FunctionId && x.ParentId != null);
                if (function != null)
                {
                    var parentFunc       = _functionRepository.FindSingle(x => x.Id == function.ParentId);
                    var parentPermission = permissionViewModels.FirstOrDefault(x => x.FunctionId == parentFunc.Id);

                    if (parentPermission.CanRead == false && permission.CanRead) // compare parent and child 'read' permission
                    {
                        return(new GenericResult(false, "Read", function.Name));
                    }
                    if (parentPermission.CanCreate == false && permission.CanCreate) // compare parent and child 'create' permission
                    {
                        return(new GenericResult(false, "Create", function.Name));
                    }
                    if (parentPermission.CanUpdate == false && permission.CanUpdate)
                    {
                        return(new GenericResult(false, "Edit", function.Name));
                    }
                    if (parentPermission.CanDelete == false && permission.CanDelete)
                    {
                        return(new GenericResult(false, "Delete", function.Name));
                    }
                }
            }
            return(new GenericResult(true));
        }
Ejemplo n.º 2
0
        public FunctionViewModel GetById(string id)
        {
            var function = _functionRepository.FindSingle(x => x.Id == id);

            return(Mapper.Map <Function, FunctionViewModel>(function));
        }
Ejemplo n.º 3
0
        public async Task <FunctionViewModel> GetById(string id)
        {
            var function = await _functionRepository.FindSingle(x => x.Id == id);

            return(new FunctionViewModel().Map(function));
        }
 public t_Function FindSingle(Expression <Func <t_Function, bool> > predicate)
 {
     return(functionRepository.FindSingle(predicate));
 }