public void DeleteChatRoom(DeleteFriendRequest room) { ChatRoom c = _chatRoomRepository.GetById(room.RoomId); UserChatRoom cr1 = _userChatRoomRepository.GetUserChatRoomByFK(room.UserId, room.RoomId); _userChatRoomRepository.Delete(cr1); c.NumOfMember--; if (c.NumOfMember == 0) { _chatRoomRepository.Delete(c); } else { _chatRoomRepository.Update(c); } }
public bool DeleteUser(int id) { List <UserChatRoom> listUserChatRoom = _userChatRoomRepository.GetAllUserChatRoom(id); foreach (UserChatRoom i in listUserChatRoom) { _userChatRoomRepository.Delete(i); } List <UserRefreshToken> listRefreshToken = _userRefreshTokenRepository.GetTokenByUID(id); foreach (UserRefreshToken i in listRefreshToken) { _userRefreshTokenRepository.Delete(i); } _userRepository.Delete(_userRepository.GetById(id)); return(true); }