Exemplo n.º 1
0
        public void Can_Perform_Delete_On_UserGroupRepository()
        {
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                UserGroupRepository repository = CreateRepository(provider);

                UserGroup userGroup = UserGroupBuilder.CreateUserGroup();

                // Act
                repository.Save(userGroup);

                int id = userGroup.Id;

                var repository2 = new UserGroupRepository((IScopeAccessor)provider, global::Umbraco.Cms.Core.Cache.AppCaches.Disabled, LoggerFactory.CreateLogger <UserGroupRepository>(), LoggerFactory, ShortStringHelper);
                repository2.Delete(userGroup);
                scope.Complete();

                IUserGroup resolved = repository2.Get((int)id);

                // Assert
                Assert.That(resolved, Is.Null);
            }
        }
        public void Can_Perform_Delete_On_UserGroupRepository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider(Logger);
            var unitOfWork = provider.GetUnitOfWork();

            using (var repository = CreateRepository(unitOfWork))
            {
                var userGroup = MockedUserGroup.CreateUserGroup();

                // Act
                repository.AddOrUpdate(userGroup);
                unitOfWork.Commit();
                var id = userGroup.Id;

                using (var repository2 = new UserGroupRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Logger, SqlSyntax))
                {
                    repository2.Delete(userGroup);
                    unitOfWork.Commit();

                    var resolved = repository2.Get(id);

                    // Assert
                    Assert.That(resolved, Is.Null);
                }
            }
        }
        public void Can_Perform_Delete_On_UserGroupRepository()
        {
            var provider = TestObjects.GetScopeProvider(Logger);

            using (var scope = ScopeProvider.CreateScope())
            {
                var repository = CreateRepository(provider);

                var userGroup = MockedUserGroup.CreateUserGroup();

                // Act
                repository.Save(userGroup);

                var id = userGroup.Id;

                var repository2 = new UserGroupRepository((IScopeAccessor)provider, Core.Cache.CacheHelper.Disabled, Logger);
                repository2.Delete(userGroup);
                scope.Complete();

                var resolved = repository2.Get(id);

                // Assert
                Assert.That(resolved, Is.Null);
            }
        }
Exemplo n.º 4
0
        public MessageResult Remove(int id)
        {
            var group = UserGroupRepository.GetById(id);

            if (group == null)
            {
                throw new ApplicationException(string.Format(UserGroupStrings.GroupNotFound, id));
            }

            if (group.BuiltIn)
            {
                return(MessageResult.Error(UserGroupStrings.CannotRemoveBuitInGroup));
            }

            var notifications = new NotificationRepository().GetUserGroupNotifications(id).ToList();

            if (notifications.Any())
            {
                var message = string.Join(",", notifications.Select(w => $"({w.Id}) \"{w.Name}\""));
                return(MessageResult.Error(string.Format(UserGroupStrings.NotificationsExist, message)));
            }

            var workflows = WorkflowRepository.GetUserGroupWorkflows(id).ToList();

            if (workflows.Any())
            {
                var message = string.Join(",", workflows.Select(w => $"({w.Id}) \"{w.Name}\""));
                return(MessageResult.Error(string.Format(UserGroupStrings.WorkflowsExist, message)));
            }

            UserGroupRepository.Delete(id);
            return(null);
        }
 public void DeleteUserGroup(long id)
 {
     _repository.Delete(id);
     _repository.SaveChanges();
 }
Exemplo n.º 6
0
 public ResponseModel Delete(UserGroup userGroup)
 {
     return(_userGroupRepository.Delete(userGroup));
 }