示例#1
0
        public Result Edit(AdminPermissionDto dto)
        {
            var validator = new AdminPermissionValidator(_adminPermissionRepository);
            var result    = validator.ValidateResult(dto);

            if (!result.Success)
            {
                return(result);
            }

            var entity = _adminPermissionRepository.Find(dto.Id);

            if (entity == null)
            {
                return(new Result().SetBlankRedirect());
            }

            Mapper.Map <AdminPermission>(dto, entity);

            _adminPermissionRepository.Update(entity);

            _unitOfWork.Commit();

            _adminPermissionRepository.MoveToParentNode("AdminPermissions", dto.Id,
                                                        dto.IsParentSelected ? dto.ParentId : null);

            AdminRoleCacheManager.ClearCache();

            return(result.SetSuccess(Messages.RecordSaved));
        }
示例#2
0
        public Result Create(AdminPermissionDto dto)
        {
            var validator = new AdminPermissionValidator(_adminPermissionRepository);
            var result    = validator.ValidateResult(dto);

            if (!result.Success)
            {
                return(result);
            }

            var entity = Mapper.Map <AdminPermission>(dto);

            _adminPermissionRepository.Insert(entity);

            _unitOfWork.Commit();
            AdminRoleCacheManager.ClearCache();

            result.Id = entity.Id;

            return(result.SetSuccess(Messages.RecordSaved));
        }