예제 #1
0
        public Permission ConvertPermissionDTOToBO(Role_PermissionDTO Role_PermissionDTO)
        {
            Permission Permission = new Permission
            {
                Id       = Role_PermissionDTO.Id,
                Code     = Role_PermissionDTO.Code,
                Name     = Role_PermissionDTO.Name,
                RoleId   = Role_PermissionDTO.RoleId,
                MenuId   = Role_PermissionDTO.MenuId,
                StatusId = Role_PermissionDTO.StatusId,
                Menu     = Role_PermissionDTO.Menu == null ? null : new Menu
                {
                    Id        = Role_PermissionDTO.Menu.Id,
                    Code      = Role_PermissionDTO.Menu.Code,
                    Name      = Role_PermissionDTO.Menu.Name,
                    Path      = Role_PermissionDTO.Menu.Path,
                    IsDeleted = Role_PermissionDTO.Menu.IsDeleted,
                    Fields    = Role_PermissionDTO.Menu.Fields?.Select(f => new Field
                    {
                        Id          = f.Id,
                        Name        = f.Name,
                        FieldTypeId = f.FieldTypeId,
                    }).ToList(),
                    Actions = Role_PermissionDTO.Menu.Actions?.Select(p => new Entities.Action
                    {
                        Id   = p.Id,
                        Name = p.Name,
                    }).ToList(),
                },
                PermissionContents = Role_PermissionDTO.PermissionContents?.Select(pf => new PermissionContent
                {
                    Id = pf.Id,
                    PermissionOperatorId = pf.PermissionOperatorId,
                    FieldId = pf.FieldId,
                    Value   = pf.Value,
                    Field   = pf.Field == null ? null : new Field
                    {
                        Id          = pf.Field.Id,
                        Name        = pf.Field.Name,
                        FieldTypeId = pf.Field.FieldTypeId,
                    },
                    PermissionOperator = pf.PermissionOperator == null ? null : new PermissionOperator
                    {
                        Id          = pf.PermissionOperator.Id,
                        Name        = pf.PermissionOperator.Name,
                        Code        = pf.PermissionOperator.Code,
                        FieldTypeId = pf.PermissionOperator.FieldTypeId,
                    }
                }).ToList(),
                PermissionActionMappings = Role_PermissionDTO.PermissionActionMappings?.Select(pp => new PermissionActionMapping
                {
                    ActionId = pp.ActionId,
                }).ToList(),
            };

            Permission.BaseLanguage = CurrentContext.Language;
            return(Permission);
        }
예제 #2
0
        public async Task <ActionResult <Role_PermissionDTO> > GetPermission([FromBody] Role_PermissionDTO Role_PermissionDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            Permission Permission = await PermissionService.Get(Role_PermissionDTO.Id);

            return(new Role_PermissionDTO(Permission));
        }
예제 #3
0
        public async Task <ActionResult <Role_PermissionDTO> > DeletePermission([FromBody] Role_PermissionDTO Role_PermissionDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            Permission Permission = ConvertPermissionDTOToBO(Role_PermissionDTO);

            Permission = await PermissionService.Delete(Permission);

            Role_PermissionDTO = new Role_PermissionDTO(Permission);
            if (Permission.IsValidated)
            {
                return(Role_PermissionDTO);
            }
            else
            {
                return(BadRequest(Role_PermissionDTO));
            }
        }