コード例 #1
0
ファイル: MemberController.cs プロジェクト: kruguva/primate
        public void RemoveMemberFromGroup(int memberId, int structuralGroupId)
        {
            using (var repository = new GroupMemberRepository(ApplicationContext.DatabaseContext.Database))
            {
                var groupMember = repository.Get(memberId, structuralGroupId);
                if (groupMember == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }

                repository.Delete(groupMember);
            }
        }
コード例 #2
0
        public void DeleteGroupMember()
        {
            GroupMemberRepository groupMemberRepository = new GroupMemberRepository(new InMemoryDbContextFactory().CreateDbContext());
            GroupModel            groupModel            = new GroupModel
            {
                Id          = Guid.NewGuid(),
                Name        = "První cenová skupina",
                Description = "Popisek testovací skupiny První cenová skupiina",
            };

            UserModel userModel = new UserModel
            {
                Id              = Guid.NewGuid(),
                Name            = "Martin",
                Surname         = "Vlach",
                Email           = "*****@*****.**",
                Password        = "******",
                TelephoneNumber = "+420420420420"
            };

            GroupMemberModel groupMemberModel = new GroupMemberModel
            {
                Id         = Guid.NewGuid(),
                Group      = groupModel,
                User       = userModel,
                Permission = PermissionEnum.Moderator
            };

            groupMemberRepository.Insert(groupMemberModel);
            var groupMemberRepositoryResponse = groupMemberRepository.GetById(groupMemberModel.Id);

            Assert.NotNull(groupMemberRepositoryResponse);
            GroupMemberRepository groupMemberRepository2 = new GroupMemberRepository(new InMemoryDbContextFactory().CreateDbContext());

            groupMemberRepository2.Delete(groupMemberModel);
            var groupMemberRepositoryResponse2 = groupMemberRepository2.GetById(groupMemberModel.Id);

            Assert.Null(groupMemberRepositoryResponse2);
        }
コード例 #3
0
        private void DeleteUser(object obj)
        {
            GroupMemberModel groupMember = groupMemberRepository.GetGroupMemberByIDS(LoggedUserID.selectedUserModel.Id, LoggedUserID.selectedUserModel.Id).FirstOrDefault();

            groupMemberRepository.Delete(groupMember);
        }
コード例 #4
0
 public void Delete() => repository.Delete(model);