Пример #1
0
        public bool AddPermission(PermissionDTO model)
        {
            var permission = model.Map <Permission>();

            _eventPublisher.EntityInserted(permission);//清缓存
            return(_permissionRepository.Add(permission));
        }
        public void TestUserPermissions()
        {
            using (Hobby.SimpleInjector.SimpleInjectorConsole.Instance.BeginLifetimeScope())
            {
                var uow = IoCCProvider.Container.GetInstance <IUnitOfWork>();

                var categorie = new CategoryDTO
                {
                    Name = "testCategorie1"
                };

                var permissions = new PermissionDTO
                {
                    Name        = "testPermission1",
                    Deleted     = false,
                    Description = "TEST"
                };

                var user = new UserDTO
                {
                    FirstName = "testlogin1",
                    Password  = "******"
                };
                //Trzeba przypsiac do obiektu
                var entityPer = permissions.Map();
                var entityUse = user.Map();

                uow.Permissions.Add(entityPer);
                uow.Users.Add(entityUse);
                uow.Save();

                var userPermission = new UserPermissionDTO()
                {
                    IdPermission = entityPer.Id,
                    IdUser       = entityUse.Id
                };
                uow.UserPermissions.Add(userPermission.Map());
                uow.Save();
            }
        }